我有以下简单的代码来连接到一个 SSL 网页。
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];
[ NSURLConnection sendSynchronousRequest: urlRequest returningResponse: nil error: &error ];
除非证书是自签名的,否则会产生错误:Error Domain=NSURLErrorDomain Code=-1202 UserInfo=0xd29930 "untrusted server certificate".
有没有办法设置它来接受连接(就像在浏览器中可以按接受一样),或者有什么方法可以绕过这个问题?
-(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
方法来替代。 - Andrew R.