https - SSL Error in Connection to Server through iPhone -
i trying establish https connection server using app. connection fails due following error
error domain=nsurlerrordomain code=-1200 "an ssl error has occurred , secure connection server cannot made." userinfo=0x612eb30 {nserrorfailingurlstringkey=https:myurl.com/signup, nslocalizedrecoverysuggestion=would connect server anyway?, nserrorfailingurlkey=https:myurl.com/signup, nslocalizeddescription=an ssl error has occurred , secure connection server cannot made., nsunderlyingerror=0x612eb70 "an ssl error has occurred , secure connection server cannot made."}
the code connect server is
-(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]; } }
my delegate methods
- (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]; }
i stuck on here , not find way out.
any form of appreciated.
thanks in advance!!
ios 9 forces connections using https tls 1.2 avoid recent vulnerabilities. in ios 8 unencrypted http connections supported, older versions of tls didn't make problems either. workaround, can add code snippet info.plist:
<key>nsapptransportsecurity</key> <dict> <key>nsallowsarbitraryloads</key> <true/> </dict>
thereby you're disabling app transport security. hope that's helpful.
Comments
Post a Comment