Created
February 3, 2022 10:12
-
-
Save aydin-emre/f0939f4650d1d5cf1637fb5622653640 to your computer and use it in GitHub Desktop.
Using SSL Pinning with Alamofire
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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