0

I´m using the AFNetworking library to perform my requests. Now I'm facing the problem with untrusted certificates. I have a constants class in wich if I set the _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ all the untrusted certificates work. If I delete that constant I receive a -1202 code error("The certificate for this server is invalid....").

My problem is that I need to allow the user to decide if they'd like to accept invalid certificates.

Do I have a way to insert/delete a #define programmatically? Thanks in advance!!

Carlos
  • 1,319
  • 2
  • 17
  • 20

3 Answers3

0

Take a look at this question. I want to allow invalid SSL certificates with AFNetworking

It has examples for how to do it. Also if you're using CocoaPods be sure to do it in the Pods pch file.

Community
  • 1
  • 1
Keith Smiley
  • 61,481
  • 12
  • 97
  • 110
  • It doesn't work because: #define _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ 1 is "readed" by AFNetworking at compile time and not "Runtime" as my answer says. – Carlos Mar 19 '13 at 15:43
0

There is already a pull request for this here https://github.com/AFNetworking/AFNetworking/pull/873. I hope this can be included for the next AFNetworking release.

Carlos
  • 1,319
  • 2
  • 17
  • 20
0

To circle back on Carlos's post above, my pull request made it into the AFNetworking 1.2.1, so grab bits from there :)

kcharwood
  • 2,501
  • 19
  • 22