0
let url string = "https://myURL"

func task(_ urlstring: String,json: AnyObject, ComplitionHandler: @escaping taskCompletionHandler  )
{
    do
    {
        let jsonData = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted)
        let url = URL(string: urlstring)
        var request = URLRequest(url: url!)
        request.httpMethod = "POST"
        request.httpBody = jsonData
        request.addValue("application/json", forHTTPHeaderField: "Content-Type")

        let task = URLSession.shared.dataTask(with: request, completionHandler: {(data,response,error) in

                if(error != nil)
                {
                    print(error)
                    ComplitionHandler(nil, nil )
                    return
                }
                ComplitionHandler(data!, response!)
        })            
        task.resume()
    }
    catch
    {
        print("error")
    }
}

I have done some Changes in .plist by adding (App Transport Security ,Allow Arbitrary Loads=YES,Allow Arbitrary Loads in Web Content=YES).

But Still getting below error:

NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://myurl, NSErrorFailingURLStringKey=https://myurl, NSErrorClientCertificateStateKey=0

CDspace
  • 2,639
  • 18
  • 30
  • 36
hatim
  • 218
  • 4
  • 16

1 Answers1

1

Well the list of trusted root certificates is updated on iOS 10, so judging on that you should make sure that your SSL Certificate is not part of iOS 10 blocked root certificates.

Updated List

If you have a WoSign CA Free SSL Certificate G2, Apple is blocking it, as they are claiming that is has multiple control failures. More info here

E-Riddie
  • 14,660
  • 7
  • 52
  • 74