title: NSURLSession/NSURLConnection HTTP load failed on Swift 4
body: <p>I have xcode 9.1 with swift 4 and i'm unable to authenticate using webview anymore. here is my code :</p>
  
  <pre><code>import UIKit
  
  protocol AuthViewControllerDelegate{
      func getAccessToken(_ code: String)
  }
  
  class AuthViewController: UIViewController, NSURLConnectionDelegate {
  
  
      @IBOutlet weak var navItem: UINavigationItem!
      @IBOutlet weak var webView: UIWebView!
  
      var delegate: AuthViewControllerDelegate?
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          var link: "https://home.nest.com/login/oauth2?client_id=…"
  
          if let encodeURL = link.URLEncodedString(), let url = URL(string: encodeURL) {
              webView.loadRequest(URLRequest(url: url))
          }
      }
  
  
      override var preferredStatusBarStyle : UIStatusBarStyle {
          return .lightContent
      }
  
      @IBAction func CancelPressed(_ sender: UIBarButtonItem) {
          self.dismiss(animated: true, completion: nil)
      }
  
      func webView(_ webView: UIWebView, shouldStartLoadWithRequest request: URLRequest, navigationType: UIWebViewNavigationType) -&gt; Bool {
          if let url = request.url?.absoluteString, url.contains("code=") {
              if let code = getQueryStringParameter(url,param: "code"){
                  self.dismiss(animated: true, completion: { () -&gt; Void in
                      UIApplication.shared.isNetworkActivityIndicatorVisible = false
                      self.delegate?.getAccessToken(code)
                  })
              }
          }
          return true
      }
  
      func webViewDidStartLoad(_ webView: UIWebView){
          UIApplication.shared.isNetworkActivityIndicatorVisible = true
      }
  
      func webViewDidFinishLoad(_ webView: UIWebView){
          UIApplication.shared.isNetworkActivityIndicatorVisible = false
      }
  
      func getQueryStringParameter(_ url: String?, param: String) -&gt; String? {
          if let url = url, let urlComponents = URLComponents(string: url), let queryItems = (urlComponents.queryItems) {
              return queryItems.filter({ (item) in item.name == param }).first?.value!
          }
          return nil
      }
  }
  </code></pre>
  
  <p>And here is the error i'm getting in the log :</p>
  
  <blockquote>
    <p>2017-11-07 20:49:30.836087+0000 TestApp[1851:1259046] TIC TCP Conn
    Failed [32:0x1c0365280]: 3:-9800 Err(-9800)</p>
    
    <p>2017-11-07 20:49:30.836472+0000 TestApp[1851:1259046]
    NSURLSession/NSURLConnection HTTP load failed 
    (kCFStreamErrorDomainSSL, -9800)</p>
    
    <p>2017-11-07 20:49:30.836578+0000 TestApp[1851:1259046] Task
    &lt;0A675AA1-7110-4FCC-99B2-054380D22F01>.&lt;0> HTTP load failed (error
    code: -1200 [3:-9800])</p>
    
    <p>2017-11-07 20:49:30.837548+0000 TestApp[1851:1258708] NSURLConnection
    finished with error - code -1200</p>
  </blockquote>
  
  <p>And i already have this into my .plist file :</p>
  
  <pre><code>&lt;dict&gt;
      &lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt;
      &lt;true/&gt;
  &lt;/dict&gt;
  </code></pre>
  
  <p>NB: The same code was working perfectly with swift 3.2</p>