Slide 42
Slide 42 text
VERIFYING TRUST
let pathToCert = Bundle.main.path(forResource: "pathtomycert", ofType: "cer")
let localCertificate:NSData = NSData(contentsOfFile: pathToCert!)!
let serverTrustPolicy = ServerTrustPolicy.pinCertificates(
certificates: [SecCertificateCreateWithData(nil, localCertificate)!],
validateCertificateChain: true,
validateHost: true
)
let serverTrustPolicies = [
"myserver.com": serverTrustPolicy
]
let alamofireManager = Alamofire.SessionManager(
configuration: URLSessionConfiguration.default,
serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies)
)
https://github.com/Alamofire/Alamofire#server-trust-policy-manager
https://www.owasp.org/index.php/Pinning_Cheat_Sheet