title: Swift client and root SSL certificate authentication
body: <p>Integrating get <code>token</code> api of <code>QLIK server</code>  with <code>ssl</code> certificate but after performing task I am getting error like this -</p>
  
  <blockquote>
    <p>"<strong>finished with error - code: -999</strong>"</p>
  </blockquote>
  
  <pre><code>// Your hostname and endpoint
  let hostname = "YOUR_HOST_NAME"
  let endpoint = "YOUR_ENDPOINT"
  let cert = "YOUR_CERT" // e.g. for cert.der, this should just be "cert"
  
  // Set up certificates
  let pathToCert = Bundle.main.path(forResource: cert, ofType: "der")
  let localCertificate = NSData(contentsOfFile: pathToCert!)
  let certificates = [SecCertificateCreateWithData(nil, localCertificate!)!]
  
  // Configure the trust policy manager
  let serverTrustPolicy = ServerTrustPolicy.pinCertificates(
      certificates: certificates,
      validateCertificateChain: true,
      validateHost: true
  )    
  let serverTrustPolicies = [hostname: serverTrustPolicy]
  let serverTrustPolicyManager = ServerTrustPolicyManager(policies: serverTrustPolicies)
  
  // Configure session manager with trust policy
  afManager = SessionManager(
      configuration: URLSessionConfiguration.default,
      serverTrustPolicyManager: serverTrustPolicyManager
  )
  
  
  
  qlikManager.request(strURL, method: .post, parameters: params, encoding: JSONEncoding.default, headers: headers).responseJSON { (responseObject) -&gt; Void in
  
         print(responseObject)
      }
  </code></pre>
  
  <p>Please check it</p>