The Charlotte iOS Developers Meetup Message Board › Invalid Certificates

Invalid Certificates

Sean Rhone
Posted Jun 18, 2012 11:19 AM
user 9537049
Charlotte, NC
Post #: 28
Send an Email Post a Greeting
It appears that over the weekend my company decided to switch SSL certificate providers and now use GoDaddy; so now when I call my web service using https I am getting an invalid certificate warning.

Tried using the connection:willSendRequestForAuthenticationChallenge to tell the connection to continue but it's not working.

Anyone have any idea's?
Mark Rickert
Posted Jun 18, 2012 1:46 PM
markrickert
Charlotte, NC
Post #: 4
Send an Email Post a Greeting
If you're using a networking library like AFNetworking or ASIHTTPRequest, its fairly trivial to tell the request to ignore invalid SSL certificates.

I'd recommend using those libraries over trying to mess with core level networking operations.
Sean Rhone
Posted Jun 18, 2012 1:59 PM
user 9537049
Charlotte, NC
Post #: 29
Send an Email Post a Greeting
Thanks for the reply Mark - I have not used those libraries yet and I'm using the core framework, maybe another time.

But I did finally solve my issue with the following

-(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{

[[challenge sender] useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}
Mark Rickert
Posted Jun 19, 2012 8:07 AM
markrickert
Charlotte, NC
Post #: 5
Send an Email Post a Greeting
Glad you figured it out.

In AFNetworking, you'd just have to:

#define AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES 1

And ASIHTTPRequest you set up your individual request and then do:

[request setValidatesSecureCertificate:NO];
Powered by mvnForum

People in this
Meetup are also in:

Log in

Not registered with us yet?

Sign up

Meetup members, Log in

or
By clicking the "Sign up using Facebook" or "Sign up" buttons above, you agree to Meetup's Terms of Service