title: PublicKey Pinning with Alamofire
body: <p>I have attached the .cer file for google.com and writing 2 method.
  first method is on to call the URL without SSL pinning :</p>
  
  <pre><code>@IBAction func Request_with_No_Pinning() {
     // let sessionManager = SessionManager()
  
      Alamofire.request("https://google.com").response { response in
          if response.response != nil{
  
              print(response.response?.debugDescription as Any)
          }
      }
  }
  </code></pre>
  
  <p>and it is working as expected.
  second method is to call google.com with PublicKey Pinning : </p>
  
  <pre><code>    @IBAction func Request_with_Pinning() {
      var sessionManager = SessionManager()
      let serverTrustPolicies: [String: ServerTrustPolicy] = [
          "google.com": .pinPublicKeys(
              publicKeys: ServerTrustPolicy.publicKeys(),
              validateCertificateChain: true,
              validateHost: true
          )
      ]
  
      sessionManager = SessionManager(
  
          serverTrustPolicyManager: ServerTrustPolicyManager(
              policies: serverTrustPolicies
          )
      )
  
  
      sessionManager.request("https://google.com").response { response in
  
          if response.response != nil{
              print(response.response?.debugDescription as Any)
          }
  
      }
  }
  </code></pre>
  
  <p>and it is giving me error : </p>
  
  <blockquote>
    <p>2019-08-28 21:55:21.230911+0300 sslpinning[7184:114068] Task .&lt;1> load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=<a href="https://google.com/" rel="nofollow noreferrer">https://google.com/</a>, NSErrorFailingURLKey=<a href="https://google.com/" rel="nofollow noreferrer">https://google.com/</a>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
        "LocalDataTask .&lt;1>"
    ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .&lt;1>, NSLocalizedDescription=cancelled} [-999]
    2019-08-28 21:55:21.232343+0300 sslpinning[7184:114069] Task .&lt;1> finished with error - code: -999</p>
  </blockquote>