La mia app si collega semplicemente a un server Web su un dispositivo domestico e legge alcuni html. Funziona bene quando si usa http, ma ora su iOS 8 quando si usa https non funziona.iOS 8 ha interrotto la connessione SSL nella mia app - CFNetwork SSLHandshake non riuscito (-9806)
Io uso AFNetworking
v1 e sovrascrivo i controlli SSL utilizzando questi metodi di sovrascrittura (Sì, lo so in circostanze normali, questo non dovrebbe essere fatto ed è pericoloso ecc., Ma questo è un altro argomento).
[self setAuthenticationChallengeBlock:^(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge) {
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}
}];
[self setAuthenticationAgainstProtectionSpaceBlock:^BOOL(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace) {
if([[protectionSpace authenticationMethod] isEqualToString:NSURLAuthenticationMethodServerTrust]) {
return YES; // Self-signed cert will be accepted
}
// If no other authentication is required, return NO for everything else
// Otherwise maybe YES for NSURLAuthenticationMethodDefault and etc.
return NO;
}];
Ora con iOS 8 ottengo un errore come questo:
CFNetwork SSLHandshake failed (-9806)
CFNetwork SSLHandshake failed (-9806)
CFNetwork SSLHandshake failed (-9806)
NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
Error during connection: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x7b66c110 {NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorCodeKey=-9806, NSErrorFailingURLStringKey= https://xxx.xxx.xxx.xxx:443/live.htm , _kCFStreamErrorDomainKey=3, NSUnderlyingError=0x7c0d8a20 "An SSL error has occurred and a secure connection to the server cannot be made.", NSErrorFailingURLKey= https://xxx.xxx.xxx.xxx:443/Info.live.htm }
Ho provato a cambiare verso FSNetworking, e sometimes
opere quando si imposta questo:
- (void)connection:(NSURLConnection *)connection
willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
{
NSLog(@"Ignoring SSL");
SecTrustRef trust = challenge.protectionSpace.serverTrust;
NSURLCredential *cred;
cred = [NSURLCredential credentialForTrust:trust];
[challenge.sender useCredential:cred forAuthenticationChallenge:challenge];
return;
}
}
Tuttavia fare 2 richieste simultanee, solo 1 avrà successo e una fallirà con un errore simile a quello sopra. Solo 1 richiesta sembra raggiungere il punto di override SSL.
Qualcuno può per favore fare un po 'di luce su questo e cosa è cambiato in iOS 8 per rompere questo, e come posso ripararlo?
Grazie
Ecco un elenco di codici di errore che include il tuo: http://www.opensource.apple.it/source/libsecurity_ssl/libsecurity_ssl-32463/lib/SecureTransport.h – eremzeit