4

我发现 NSUrlConnection 的所有这些变通方法都使用封闭的 API 来访问不受信任的 SSL 证书。其他选项是首先使用 Safari/Mail 应用程序安装证书。

我想知道安装了哪些根证书,所以我可以从受信任的 CA 获得一个,你应该这样做的方式..

任何人都知道我需要什么 CA?

4

2 回答 2

3

这是 iphone 上预装的可用 CA 的列表

http://support.apple.com/kb/HT2185

您可以让任何这些权威机构签署您的证书,或者您可以签署自己的证书并使用 OpenSSL 创建自己的 CA

于 2010-05-17T22:11:25.880 回答
0

实际上,您可以使用公共 API 接受自签名 SSL 证书:

- (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]) {
        [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
    }

    [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
于 2012-02-20T13:43:35.027 回答