我想在Alamofire
. 这是我的代码:
// Set up certificates
let pathToCert = Bundle.main.path(forResource: cert, ofType: "der")
let localCertificate = NSData(contentsOfFile: pathToCert!)
let certificates = [SecCertificateCreateWithData(nil, localCertificate!)!]
// Configure the trust policy manager
let serverTrustPolicy = ServerTrustPolicy.pinCertificates(
certificates: ServerTrustPolicy.certificates(),
validateCertificateChain: false,
validateHost: true)
let serverTrustPolicies = ["hostname": serverTrustPolicy]
let serverTrustPolicyManager = ServerTrustPolicyManager(policies: serverTrustPolicies)
let sessionManager = SessionManager(configuration: URLSessionConfiguration.default,serverTrustPolicyManager: serverTrustPolicyManager)
sessionManager
.request()...
这是我的 info.plist ->
我得到这个错误:
load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled"
我搜索了很多,但找不到任何可以解决我的问题的东西。我.crt
使用. .der
_open ssl