title: How to send HTTPS POST request in swift using NSURLSession
body: <p>I've been developing using HTTP. The code below works great when connecting with the development server using HTTP. However, when I change the scheme to https, it doesn't send a successful https post to the server.</p>
  
  <p>What else do I need to do to switch from HTTP POST to HTTPS POST?</p>
  
  <pre><code>class func loginRemote(successHandler:()-&gt;(), errorHandler:(String)-&gt;()) {
  
      let user = User.sharedInstance
  
      // this is where I've been changing the scheme to https
      url = NSURL(String: "http://url.to/login.page") 
  
      let request = NSMutableURLRequest(URL: url)
  
      let bodyData = "email=\(user.email)&amp;password=\(user.password)"
      request.HTTPBody = bodyData.dataUsingEncoding(NSUTF8StringEncoding);
  
      request.HTTPMethod = "POST"
  
      let session = NSURLSession.sharedSession()
  
      // posting login request
      let task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -&gt; Void in
          if let httpResponse = response as? NSHTTPURLResponse {
              if httpResponse.statusCode == 200 {
                  // email+password were good
  
                  successHandler()                    
  
              } else {
                  // email+password were bad
                  errorHandler("Status: \(httpResponse.statusCode) and Response: \(httpResponse)")
              }
          } else {
              NSLog("Unwrapping NSHTTPResponse failed")
          }
      })
  
      task.resume()
  }
  </code></pre>