Ignoring certificate errors with NSURLConnection

前端 未结 6 1386
臣服心动
臣服心动 2020-11-30 08:42

I am getting this error

The certificate for this server is invalid. You might be connecting to a server
that is pretending to be \"server addres goes here\"         


        
6条回答
  •  孤城傲影
    2020-11-30 09:24

    You've set the delegate as self, so you can fix this by implementing part of NSURLConnectionDelegate in the class sending that request.

    Implement this:

    -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
    

    By doing this:

    [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
    

    Note: this is NOT a solution to use in production. Certificates exist for a reason! :)

提交回复
热议问题