1

I am using following code to fetch the data over HTTPS self signed service

    let session = URLSession.shared
    let task = session.dataTask(with: urlRequest as URLRequest) {
        (data, response, error) -> Void in
        if response != nil {
            let httpResponse = response as! HTTPURLResponse
            let statusCode = httpResponse.statusCode

            if (statusCode == 200) {
                let response = ServerResponse()
                response.responsedata = data as! NSMutableData
                response.httpResponse = httpResponse
                completionHandler(response)
            }
            else {
                let response = ServerResponse()
                response.responsedata = data as! NSMutableData
                response.httpResponse = httpResponse
                completionHandler(response)
            }
        }
        else{
            let response = ServerResponse()
            response.responsedata = nil
            response.httpResponse = nil
            completionHandler(response)
        }
    }
    task.resume()

But it is giving

SURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)

Can some one help me on this how to overcome the issue?

Sravan P
  • 11
  • 3

0 Answers0