使用Alamofire 3.x,有没有办法打印出serverTrustPolicy失败的原因?目前,我手动将值从true更改为false以测试错误的证书。在这个例子中,我定义了一个错误的证书==自签名或不正确的主机名。
class PinningManager {
var manager: Manager?
init() {
let serverTrustPolicies: [String: ServerTrustPolicy] = [
"google.com": .PinCertificates(
certificates: ServerTrustPolicy.certificatesInBundle(),
validateCertificateChain: true,
validateHost: true
),
"httpbin.org": .DisableEvaluation
]
manager = Alamofire.Manager(
configuration: NSURLSessionConfiguration.defaultSessionConfiguration(),
serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies)
)
}
}