title: Swift and Alamofire SSL Pinning and Handling Challenge
body: <p>I need to handle the challenge when I try to get the json from my internal web server.  I followed <a href="https://stackoverflow.com/questions/36641243/get-json-result-with-get-request-and-parameters-with-alamofire">this</a> from a previous question.  Here is my code </p>
  
  <pre><code>let defaultManager: Alamofire.SessionManager = {
              let serverTrustPolicies: [String: ServerTrustPolicy] = [
                  "myhttpsinternaldomain.org": .disableEvaluation
              ]
  
              let configuration = URLSessionConfiguration.default
              configuration.httpAdditionalHeaders = Alamofire.SessionManager.defaultHTTPHeaders
  
              return Alamofire.SessionManager(
                  configuration: configuration,
                  serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies)
              )
          }()
  
          let url = URL(string: urlString)
          let username = "user"
          let password = "password"
          let header = ["user": username, "password": password]
  
          defaultManager.request(url!, method: .get, headers: header).responseJSON { response in
              switch response.result {
              case .success(let value):
                  let json = JSON(value)
                  print("JSON: \(json)")
              case .failure(let error):
                  print(error)
              }
          }
  </code></pre>
  
  <p>This is the error I receive</p>
  
  <blockquote>
    <p>Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=<a href="https://myhttpsinternaldomain.org" rel="nofollow noreferrer">https://myhttpsinternaldomain.org</a>, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=<a href="https://myhttpsinternaldomain.org" rel="nofollow noreferrer">https://myhttpsinternaldomain.org</a>}</p>
  </blockquote>
  
  <p>I found <a href="https://stackoverflow.com/questions/40447436/alamofire-error-domain-nsurlerrordomain-code-999-cancelled">this</a> but I don't have the tokens in my project.  I want to just user the username and password or ignore the challenge</p>
  
  <p>Please any help</p>