ios - AFNetworking need to bypass ssl checking -


i have app connects directly hardware routers. since ios 9 updated afnetworking , getting ssl errors when attempt connect on https.

this isn't ios 9 app transport security issue, have added relevant .plist entry bypass , connections work fine on http.

i need bypass certificate checking each router has it's own self signed certificate, can't add certificates app every users different.

i use afhttprequestoperation subclass connections , have set self.securitypolicy.allowinvalidcertificates = yes; following error:

error during connection: error domain=nsurlerrordomain code=-1200 "an ssl error has occurred , secure connection server cannot made." userinfo={_kcfstreamerrorcodekey=-9806, nslocalizedrecoverysuggestion=would connect server anyway?, nsunderlyingerror=0x7fa9f3611b40 {error domain=kcferrordomaincfnetwork code=-1200 "an ssl error has occurred , secure connection server cannot made." userinfo={nserrorfailingurlstringkey=https://myserver.com:4780/info.htm, nslocalizedrecoverysuggestion=would connect server anyway?, _kcfnetworkcfstreamsslerrororiginalvalue=-9806, _kcfstreampropertysslclientcertificatestate=0, nslocalizeddescription=an ssl error has occurred , secure connection server cannot made., _kcfstreamerrordomainkey=3, nserrorfailingurlkey=https://myserver.com:4780/info.htm, _kcfstreamerrorcodekey=-9806}}, nslocalizeddescription=an ssl error has occurred , secure connection server cannot made., nserrorfailingurlkey=https://myserver.com:4780/info.htm, nserrorfailingurlstringkey=https://myserver.com:4780/info.htm, _kcfstreamerrordomainkey=3}

i've tried adding setwillsendrequestforauthenticationchallengeblock: block never gets called.

can please help?

thanks

edit ----- setting self.securitypolicy.validatesdomainname = no; doesn't work. wonder if it's problem type of certificate on hardware.

edit 2 ----- here's certificate

new, tlsv1/sslv3, cipher des-cbc3-sha server public key 2048 bit secure renegotiation not supported compression: none expansion: none ssl-session: protocol : sslv3 cipher : des-cbc3-sha session-id: 010000000c6b8632215649c0665e9dcc9ec59e22f8f021672b6b50b84222a342 session-id-ctx: master-key: d71ec7d8f7a4a3581e25cdad9c532b2c7b4da8b513af337095496b575f525cfba02a40797b2d2a4f0b5911efefc3623f key-arg : none start time: 1443102149 timeout : 300 (sec) verify return code: 18 (self signed certificate)

edit 3 -------- adding code afhttprequestoperation subclass makes work on ios 8, block isn't called on ios 9.

[self setwillsendrequestforauthenticationchallengeblock:^(nsurlconnection * _nonnull connection, nsurlauthenticationchallenge * _nonnull challenge)     {         nslog(@"**** here ****");         if ([challenge.protectionspace.authenticationmethod isequaltostring:nsurlauthenticationmethodservertrust])         {             [challenge.sender usecredential:[nsurlcredential credentialfortrust:challenge.protectionspace.servertrust] forauthenticationchallenge:challenge];         }         [challenge.sender continuewithoutcredentialforauthenticationchallenge:challenge];     }]; 

i encountered similar problems , in case solved setting security policy afsslpinningmodenone , allowing invalid certificates.

an example in obj-c:

afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager];  afsecuritypolicy *securitypolicy = [afsecuritypolicy policywithpinningmode:afsslpinningmodenone]; securitypolicy.allowinvalidcertificates = yes; manager.securitypolicy = securitypolicy;  [manager post:url parameters:nil success:^(afhttprequestoperation *operation, id responseobject) {     nslog(@"response: %@",responseobject); } failure:^(afhttprequestoperation *operation, nserror *error) {     nslog(@"error: %@", error); }]; 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -