ios - NSURLSession didReceiveChallenge is not being call for error (kCFStreamErrorDomainSSL, -9813) -


i trying make nsurlsession request , kept getting error (kcfstreamerrordomainssl, -9813), below code -

let urlpath = "https://myurl"     func jsonparser() {             guard let endpoint = nsurl(string: urlpath) else {                 print("error creating endpoint")                 return             }             let request = nsmutableurlrequest(url:endpoint)             nsurlsession.sharedsession().datataskwithrequest(request) { (data, response, error) in                 {                     guard let data = data else {                         throw jsonerror.nodata                     }                     guard let json = try nsjsonserialization.jsonobjectwithdata(data, options: []) as? nsdictionary else {                         throw jsonerror.conversionfailed                     }                     print(json)                 } catch let error jsonerror {                     print(error.rawvalue)                 } catch let error nserror {                     print(error.debugdescription)                 }                 }.resume()         } 

to resolve error added code, somehow below code not called , still getting same error -

func urlsession(session: nsurlsession, didreceivechallenge challenge: nsurlauthenticationchallenge, completionhandler: (nsurlsessionauthchallengedisposition, nsurlcredential?) -> void) {           if let xmturl = urlpath, xmthost = xmturl.host {             if challenge.protectionspace.authenticationmethod == nsurlauthenticationmethodservertrust &&                 challenge.protectionspace.host == xmthost {                 let mycredential = nsurlcredential(trust: challenge.protectionspace.servertrust!)                 completionhandler(nsurlsessionauthchallengedisposition.usecredential, mycredential)             }         }       } 

please help. thanks!


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -