所以我想在我的应用程序中使用SSL固定,但是经过多次测试后,它仍然没有通过
我正在使用Alamofire,这是我的代码
<div id='app'></div>
这是我的要求。
public class MySessionManager {
let defaultManager: SessionManager = {
let pathToCert = Bundle.main.path(forResource: "myCertificate", ofType: "der")
let localCertificate: NSData = NSData(contentsOfFile: pathToCert!)!
let serverTrustPolicy = ServerTrustPolicy.pinCertificates(
certificates: [SecCertificateCreateWithData(nil, localCertificate)!],
validateCertificateChain: true,
validateHost: true
)
let serverTrustPolicies = ["https://myurl.com" : serverTrustPolicy]
let policyManager = ServerTrustPolicyManager(policies: serverTrustPolicies)
return SessionManager(configuration: .default, serverTrustPolicyManager: policyManager)
}()
static let sharedInstances = MySessionManager()
}
这是最新的代码,我以前已经使用过共享实例,但stil未通过测试
我想念什么?