次のエラーが表示されます: エラー Domain=NSURLErrorDomain Code=-1202 "このサーバーの証明書は無効です。「api.linkedin.com」になりすましたサーバーに接続している可能性があり、機密情報が危険にさらされる可能性があります。 ." UserInfo=0x1c53e630
これはシミュレーターでは正常に機能しますが、デバイスでは上記のエラーが発生します。
それを修正するのを手伝ってください。
このコードを試してください:
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
if ([trustedHosts containsObject:challenge.protectionSpace.host])
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
役立つことを願っています