Skip to content

Instantly share code, notes, and snippets.

@aydin-emre
Created February 3, 2022 10:12
Show Gist options
  • Save aydin-emre/f0939f4650d1d5cf1637fb5622653640 to your computer and use it in GitHub Desktop.
Save aydin-emre/f0939f4650d1d5cf1637fb5622653640 to your computer and use it in GitHub Desktop.
Using SSL Pinning with Alamofire
let file_der = Bundle(for: type(of: self)).path(forResource: "easmart", ofType: "der")
let localCertificate = NSData(contentsOfFile: file_der!)!
let serverTrustPolicy = ServerTrustPolicy.pinCertificates(
certificates : [SecCertificateCreateWithData(nil, localCertificate)!],
validateCertificateChain : true,
validateHost : true
)
let serverTrustPolicies = ["easmart.co": serverTrustPolicy]
let sessionManager = SessionManager(serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment