title: Error Domain=NSURLErrorDomain Code=-999 "cancelled" Xcode
body: <p>I am trying to make a request to a server which is https but does not have <code>SSL</code>.</p>
  
  <p>I tried to ignore ssl Certificate verification in my code below :   </p>
  
  <pre><code>func loadInfoAny(parameters: parameters, url: "https://domain/WebApiMobileGateway/api/MobileGatewayApi/PreActivation", completionHandler:@escaping (Bool, [[String: Any]]?) -&gt; ()) {
      let headers: HTTPHeaders = [
          "Content-Type": "application/json"
      ]
  
  
      let sessionManager = SessionManager()
      sessionManager.delegate.taskDidReceiveChallengeWithCompletion = { (_, _, challenge, completionHandler) -&gt; Void in
          // Pass test server with self signed certificate
          if challenge.protectionSpace.host == url {
              completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!))
          } else {
              completionHandler(.performDefaultHandling, nil)
          }
      }
  
      sessionManager.request(url, method:.post, parameters: parameters, headers : headers)
          .validate()
          .responseJSON { response in
  
              switch response.result {
  
              case let .success(value):
  
                   print(value)
  
              case let .failure(error):
                  print(error)
                  completionHandler(false, nil)
              }
      }
  
  }
  </code></pre>
  
  <p>But I get this error:</p>
  
  <blockquote>
    <p>Error Domain=NSURLErrorDomain Code=-999 "cancelled"
    UserInfo={NSErrorFailingURLStringKey=<a href="https://domain/WebApiMobileGateway/api/MobileGatewayApi/PreActivation" rel="nofollow noreferrer">https://domain/WebApiMobileGateway/api/MobileGatewayApi/PreActivation</a>, NSLocalizedDescription=cancelled,
    NSErrorFailingURLKey=<a href="https://domain/WebApiMobileGateway/api/MobileGatewayApi/PreActivation" rel="nofollow noreferrer">https://domain/WebApiMobileGateway/api/MobileGatewayApi/PreActivation</a>}.</p>
  </blockquote>
  
  <p>I've tried adding the domain to my <code>NSAppTransportSecurity</code> in <code>Info.plist</code> but that did not work. Turning on <code>NSAllowsArbitraryLoads</code> didn't work either. </p>
  
  <p>Any help would be appreciated.</p>