0
当连接到客户端的服务器时,我得到(kCFStreamErrorDomainSSL,-9813)。iOS - (kCFStreamErrorDomainSSL,-9813)
客户端的服务器有一个我不能更改的自签名证书。该应用程序正在使用AFNetworking 3.x.我试过以下,但似乎没有任何工作。
如果有人可以帮助我,它将不胜感激。
的Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key> *** CLIENT HOSTNAME *** </key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSTemporaryExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
AFNetworking连接管理器:
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
#ifdef USE_SELF_SIGNED_CERT_RULES
manager.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
manager.securityPolicy.allowInvalidCertificates = YES;
manager.securityPolicy.validatesDomainName = YES;
#endif
谢谢穆罕默德,它像一个魅力工作。我做了你所说的,我分类了evaluateServerTrust:然后在需要时在setSessionDidReceiveAuthenticationChallengeBlock中调用它。 – PerroVerde