アプリを使用してサーバーへのHTTPS接続を確立しようとしています。しかし、次のエラーのために接続が失敗します
エラードメイン=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=%@"
,@"abc@example.com",@"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];
}
私はここで立ち往生していて、逃げ道を見つけることができませんでした。
どんな形の助けも大歓迎です。
前もって感謝します!!