我正尝试使用我的应用程序建立与服务器的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