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