我正在尝试连接到 iOS 9.1 上的自签名 HTTPS 服务器。
我在用着 :
[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
我收到一条错误消息,指出证书无效:
Error Domain=NSURLErrorDomain Code=-1202 "<French error saying the certificate is invalid"
UserInfo=
{NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x13c768140>,
NSLocalizedRecoverySuggestion=<French recovery suggestion asking if the user wants to connect anyway>, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9813, NSErrorPeerCertificateChainKey=<CFArray 0x13d82ffe0 [0x1a1242b68]>
我已经尝试添加所有可能的传输安全异常,我目前的尝试是:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>mydomain.org</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
我也尝试过NSAllowsArbitraryLoads
,但即使这样也行不通。我有几个 .plist 文件(cocoapods 和测试),我认为它在正确的文件中(App/Supporting Files/Info.plist)。
知道可能出了什么问题吗?