我正嘗試使用我的應用程序建立與服務器的HTTPS連接。但由於以下錯誤導致連接失敗通過iPhone連接到服務器的SSL錯誤
錯誤域= NSURLErrorDomain代碼= -1200「發生了SSL錯誤,並且無法建立與服務器的安全連接。 UserInfo = 0x612eb30 {NSErrorFailingURLStringKey = https:myURL.com/signup,NSLocalizedRecoverySuggestion =你想連接到服務器嗎?,NSErrorFailingURLKey = https:myURL.com/signup,NSLocalizedDescription =發生了SSL錯誤,並且安全地連接到服務器無法進行,NSUnderlyingError = 0x612eb70「發生SSL錯誤和服務器的安全連接無法進行。」}
連接到服務器的代碼是
-(IBAction) handleEvents:(id)sender
{
if ((UIButton*)sender == submit) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSLog(@"Begin");
NSData *urlData;
NSURLResponse *response;
NSError *error;
NSString *url =[[NSString alloc]initWithFormat:@"%@signup",baseURL];
NSURL *theURL =[NSURL URLWithString:url];
NSMutableURLRequest *theRequest =[NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:0.0f];
[theRequest setHTTPMethod:@"POST"];
NSString *theBodyString = [NSString stringWithFormat:@"emailId=%@&mobileNumber=%@&appId=%@&password=%@&firstName=%@&lastName=%@"
,@"[email protected]",@"919879876780",@"bf1c7a6b3d266a7fe350fcfc4dda275211c13c23" ,@"qwerty" , @"Dev" , @"Sri"];
NSData *theBodyData = [theBodyString dataUsingEncoding:NSUTF8StringEncoding];
[theRequest setHTTPBody:theBodyData];
urlData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
}
}
我的委託方法有
- (void)handleError:(NSError *)error
{
NSLog(@"----->%@",error);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge (NSURLAuthenticationChallenge *)challenge {
NSLog(@"check auth");
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
我被困在這裏,找不到任何出路。
任何形式的幫助將不勝感激。
在此先感謝!
你如何解決這個地方發展? – 2015-10-05 05:39:12
不是CA的問題,只是因爲SSL的版本太低。 – 2016-12-08 10:02:58