我试图连接到iOS 9.1上的自签名HTTPS服务器。iOS应用程序传输安全性例外不起作用
我使用:
[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)。
有什么想法可能是错的?
我试过这个,但没有奏效。 – Julien