NSURLProtocolでNSURLSessionを使用してトラフィックを捕捉し、UIWebViewのプロキシ経由でチャネリングします。無効な証明書を持っている私は、ブラウザのHTTPSサイトは、その後のUIWebViewをして失敗した場合:NSURLSessionの信頼できない証明書エラーがiOS 10のカスタムプロトコルで機能しない
Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “revoked.grc.com” which could put your confidential information at risk." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLKey=, NSErrorFailingURLStringKey=, NSErrorPeerCertificateChainKey=( "", "" ), NSErrorClientCertificateStateKey=0, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “revoked.grc.com” which could put your confidential information at risk., _kCFStreamErrorDomainKey=3, NSUnderlyingError=0x170255420 {Error Domain=kCFErrorDomainCFNetwork Code=-1202 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=, _kCFNetworkCFStreamSSLErrorOriginalValue=-9807, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9807, kCFStreamPropertySSLPeerCertificates=( "", "" )}}, _kCFStreamErrorCodeKey=-9807}
のiOS 9で、下が、iOSの10で、それは次のエラー与える:私はiOSの10中のSO
Error Domain=kCFErrorDomainCFNetwork Code=310 "There was a problem communicating with the secure web proxy server (HTTPS)." UserInfo={NSErrorFailingURLStringKey=, NSErrorFailingURLKey=, _kCFStreamErrorCodeKey=-2096, _kCFStreamErrorDomainKey=4, NSLocalizedRecoverySuggestion=Please check your proxy settings. For help with this problem, contact your system administrator., NSLocalizedDescription=There was a problem communicating with the secure web proxy server (HTTPS).}
をプロキシを通過している信頼されていないサイトの方法を把握することはできません。 NSURLProtocol(NSURLSession)にプロキシのない無効な証明書を持つサイトがある場合は、iOS 10でも正常に動作します。
didReceiveChallengeデリゲートメソッドの実装。
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]){ SecTrustRef trust = [[challenge protectionSpace] serverTrust]; SecCertificateRef cert = SecTrustGetCertificateAtIndex(trust, 0); if ([[appDelegate certStore] containsCertificate:cert]) { completionHandler(NSURLSessionAuthChallengeUseCredential,[NSURLCredential credentialForTrust:trust]); return; } } completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
私はplistでATSをtrueに設定しました。 NSAppTransportSecurity \t \t \t NSAllowsArbitraryLoads \t \t \t –
user1878752
そして、それはその変化に取り組んでいますか? – dgatwood
同じことはまだありません、私のプロジェクトにはATS真がすでにあります。 – user1878752