3

In RestKit 0.2, how do I allow my app to connect to a server with an invalid https security certificate? From the AFNetworking documentation it looks like all I have to do is #define _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ . However, I've added that command to my pch file, to Build Settings > Preprocessor Macros, and to my App Delegate. All of which fail to allow the connection. Any ideas?

3
  • 1
    When I added AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES Build Settings > Preprocessor Macros on the sub project RestKit, it finally ignored the certificate. Any idea why I had to put it on the subproject and it wasn't picked up in my main project? Dec 17, 2012 at 4:08
  • Where did you have the #define? Dec 18, 2012 at 3:25
  • Nevermind, looks like in your question you describe the #define as being declared in your App Delegate. Dec 18, 2012 at 4:06

3 Answers 3

7

It would appear that the only way to accept invalid certificates is to go to the RestKit subproject, go to Build Settings > Preprocessor Macros and add the value _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ . You then need to clean your project.

I'm guessing that because the RestKit subproject contains AFNetworking some sort of pre-compilation is going on that cannot be reversed in your main project. So if you have the flag in the RestKit Build Settings, RestKit will compile with support for invalid certificates. Otherwise, by default, it will not.

1
  • 2
    This is closest I've seen to an explanation, but that still doesn't really make sense. Why would the allowsInvalidSSLCertificate property exist if setting it in the main project would just ignore it?
    – Kyle Clegg
    Jun 26, 2013 at 23:19
6

Choose the Pods project > Build Settings > Preprocessor Macros and add _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ to the Debug entry.

0

In case you're using Pods, make sure to add _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ into AFNetworking subproject, not RestKit. Besides, you'll probably need to fix your NSAppTransportSecurity settings in your .plist file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.