HI I wanted to implement the SSL pinning using public keys & I'm using Alamofire 4.8.2 Below is the code for that
func testWithAlmofire(){
let serverTrustPolicies:[String:ServerTrustPolicy] = [
"example.com": .pinPublicKeys(publicKeys: ServerTrustPolicy.publicKeys(), validateCertificateChain: true, validateHost: true)
]
sessionManager = SessionManager(
serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies)
)
sessionManager.request("https://example.com").response{ res in
if res.response != nil{
self.displayAlert(withTitle: "Test Result",
message: "Pinning validation succeeded")
}else{
self.displayAlert(withTitle: "Test Result",
message: "Pinning validation Failed")
}
}
}
Please help me if I'm doing anything wrong.
I'm using something like that, I hope this helps
You can use like that
I tried to use an example with all options used in a requisition(body, header) because I think you gonna need to use this in some moment. the code bellow is those objects used in every requisition that I create separately