Hi,
I want to implement the SSL in webservice call. But having an error as below:
NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
My code Below
func checkNetworkConnection(callback: ((isConnected: Bool) -> Void)!)
{
var checkNetworkURL: String = “TESTURL”
var request = NSMutableURLRequest(URL: NSURL(string: checkNetworkURL)!)
request.HTTPMethod = "POST"
request.addValue("application/xml", forHTTPHeaderField: "Content-Type")
request.addValue("application/xml", forHTTPHeaderField: "Accept")
request.timeoutInterval = 20000.0
var response: NSURLResponse?
var error: NSError?
var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: &error)
if error == nil{
if data != nil{
self.parser.getLoginResultDataDictionary(data!) {(dataDictionary) -> Void in
if let dataDict = dataDictionary[self.constants.defaultsKeys.RESPONSE_RESULT] as? Dictionary<String,String>
{
if let status: AnyObject = dataDict[self.constants.defaultsKeys.RESPONSE_STATUS] {
if status as! String == self.constants.defaultsKeys.RESPONSE_SUCCESS {
callback(isConnected: true)
}
else{
callback(isConnected: false)
}
}
else{
callback(isConnected: false)
}
}
else{
callback(isConnected: false)
}
}
}
else{
callback(isConnected: false)
}
}
else{
callback(isConnected: false)
}
/
}
Method added
public func connection(connection: NSURLConnection, willSendRequestForAuthenticationChallenge challenge: NSURLAuthenticationChallenge)
{
challenge.sender.useCredential(NSURLCredential(forTrust: challenge.protectionSpace.serverTrust), forAuthenticationChallenge: challenge)
challenge.sender.continueWithoutCredentialForAuthenticationChallenge(challenge)
}
Added Delegate as below
public class NetworkUtil : NSObject, NSURLConnectionDelegate { }
How can i configure SSL in the above code?
Thanks,