Le service HTTPS ne fonctionne pas

Je veux me connecter en utilisant le service web.

Mon site Web est basé sur https. J'utilise le tutoriel suivant.

http://agilewarrior.wordpress.com/2012/02/01/how-to-make-http-request-from-iphone-and-parse-json-result/ 

Le code suivant fonctionne correctement.

 responseData = [NSMutableData data]; NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithSsortingng:@"https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AIzaSyAbgGH36jnyow0MbJNP4g6INkMXqgKFfHk"]]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; 

mais mon code est

 responseData = [NSMutableData data]; NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithSsortingng:@"https:myurl/login?userId=username&password=111111"]]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; 

et ça donne une erreur

 Connection failed: Error Domain=NSURLErrorDomain Code=-1202 "The certificatee for this server is invalid. You might be connecting to a server that is pretending to be --My URL-- which could put your confidential information at risk." UserInfo=0xa294260 {NSErrorFailingURLSsortingngKey=https://mywebsite/login?userId=username&password=111111, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLKey=https://mywebsite/login?userId=username&password=111111, NSLocalizedDescription=The certificatee for this server is invalid. You might be connecting to a server that is pretending to be --My URL-- which could put your confidential information at risk., NSUnderlyingError=0xa5befc0 "The certificatee for this server is invalid. You might be connecting to a server that is pretending to be --My URL-- which could put your confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0xa5768d0>} 

C'est un problème avec le site Web auquel vous vous connectez, pas le code. S'il ne possède pas de certificate connu, il sera traité comme un risque de security.

Ce qui se passe, c'est que votre certificate n'est pas valide (du sharepoint vue de votre application). Si vous voulez prendre le risque, vous pouvez append le code suivant.

 - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { return [protectionSpace.authenticationMethod isEqualToSsortingng:NSURLAuthenticationMethodServerTrust]; } - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { NSArray * trustedHosts = @[@"your domain"]; if ([challenge.protectionSpace.authenticationMethod isEqualToSsortingng:NSURLAuthenticationMethodServerTrust]) if ([trustedHosts containsObject:challenge.protectionSpace.host]) [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge]; } 

Donc le certificate sera ignoré. (N'oubliez pas de replace "votre domaine" par votre domaine.)