I have an application that connects directly to hardware routers. Since iOS 9 I updated AFNetworking and now I get ssl errors when I try to connect via https .
This is not a problem with iOS 9 App Transport Security since I added the appropriate .plist entry to get around it, and the connections work fine on http .
I need to bypass certificate verification, since each router has its own certificate, so I obviously can not add certificates to my application, since each user is different.
I use the AFHTTPRequestOperation subclass for connections and set self.securityPolicy.allowInvalidCertificates = YES; but I get the following error:
Connection error: Domain error = NSURLErrorDomain Code = -1200 "An SSL error occurred and a secure connection to the server could not be made." UserInfo = {_ kCFStreamErrorCodeKey = -9806, NSLocalizedRecoverySuggestion = Do you want to connect to the server? anyway ?, NSUnderlyingError = 0x7fa9f3611b40 {Error Domain = kCFErrorDomainCFNetwork Code = -1200 "An SSL error has occurred and a secure connection to the server is not possible." UserInfo = {NSErrorFailingURLStringKey = https://myserver.com:4780/Info.htm , NSLocalizedRecoverySuggestion = Do you want to connect to the server? anyway ?, _kCFNetworkCFStreamSSLErrorOriginalValue = -9806, _kCFStreamPropertySSLClientCertificateState = 0, NSLocalizedDescription = SSL error and a secure connection to the server could not be made., _kCFStreamErrorDomainKeyrermerererererererererererererererererererererererferrmererring_remerfery = -9806}}, NSLocalizedDescription = An SSL error occurred and a secure connection to the server could not be created. NSErrorFailingURLKey = https://myserver.com:4780/Info.htm , NSErrorFailingURLStringKey = https://myserver.com:4780/Info.htm , _kCFStreamErrorDomainKey = 3}
I also tried adding setWillSendRequestForAuthenticationChallengeBlock: however the block is never called.
Can anybody help?
thanks
EDIT ----- Setting self.securityPolicy.validatesDomainName = NO; also does not work. Interestingly, there is no problem with the type of certificate on the hardware.
EDIT 2 ----- Here is the certificate
New, TLSv1 / SSLv3, Cipher is the public key DES-CBC3-SHA Server 2048 bit Secure Renegotiation is NOT supported by compression: NONE Extension: NONE SSL session: protocol: SSLv3 Cipher: DES-CBC3-SHA Session identifier: 010000000C6B8632215649C0665E9DCC9B2222B2222B2222B2272B220072B22BB22B ctx: Master key: D71EC7D8F7A4A3581E25CDAD9C532B2C7B4DA8B513AF337095496B575F525CFBA02A40797B2D2A4F0B5911EFEFC3623F Key-Arg: no Start time: 1443102149 Self-signed (Confirm): Timeout: 1848: Confirm: 1841
EDIT 3 -------- Adding this code to my subclass of AFHTTPRequestOperation makes it work on iOS 8, however the block is not even called in iOS 9.
[self setWillSendRequestForAuthenticationChallengeBlock:^(NSURLConnection * _Nonnull connection, NSURLAuthenticationChallenge * _Nonnull challenge) { NSLog(@"**** HERE ****"); if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; } [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge]; }];