5

次のエラーが表示されます: エラー Domain=NSURLErrorDomain Code=-1202 "このサーバーの証明書は無効です。「api.linkedin.com」になりすましたサーバーに接続している可能性があり、機密情報が危険にさらされる可能性があります。 ." UserInfo=0x1c53e630

これはシミュレーターでは正常に機能しますが、デバイスでは上記のエラーが発生します。

それを修正するのを手伝ってください。

4

2 に答える 2

-2

このコードを試してください:

- (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];
}

役立つことを願っています

于 2013-08-24T09:23:00.687 に答える