Created
July 16, 2019 11:15
-
-
Save sagaya/35ad4972d1471342dfa21a5523a2eee3 to your computer and use it in GitHub Desktop.
ssl_pining
This file contains 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 pathToCert = Bundle.main.path(forResource: "name-of-cert-file", ofType: "cer") | |
let localCertificate: NSData = NSData(contentsOfFile: pathToCert!)! | |
let serverTrustPolicy = ServerTrustPolicy.pinCertificates( | |
certificates: [SecCertificateCreateWithData(nil, localCertificate)!], | |
validateCertificateChain: true, | |
validateHost: true | |
) | |
let serverTrustPolicies = [ | |
"my-server.com": 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