NSURL *url = [NSURL URLWithString:@"https://myUrlString.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLResponse *responseurl;
NSError *err;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&responseurl error:&err];
NSLog(@"data length:%u", data.length);
NSLog(@"response:%@ , error:%@", responseurl, err);
我得到的回应是:-
data length:0
response:(null) ,
错误:错误域=NSURLErrorDomain 代码=-1202 “此服务器的证书无效。您可能正在连接到伪装成“myUrlString.com”的服务器,这可能会使您的机密信息面临风险。” UserInfo=0x8742d70 {NSErrorFailingURLStringKey=https:https://myUrlString.com,
NSLocalizedRecoverySuggestion=你还是要连接到服务器吗?,
NSErrorFailingURLKey=https://myUrlString.com,
NSLocalizedDescription=此服务器的证书无效。您可能正在连接到伪装成“myUrlString.com”的服务器,这可能会使您的机密信息面临风险。NSUnderlyingError=0x8745bf0 " The certificate for this server is invalid. You might be connecting to a server that is pretending to be “myUrlString.com” which could put your confidential information at risk.
", NSURLErrorFailingURLPeerTrustErrorKey=}