private static func pinningManager() -> Session {
let configuration = URLSessionConfiguration.default
configuration.headers = .default
let certificationData = try? NSData(contentsOf: R.file.releaseIguoxiaodiComCer()!)
let certificate = SecCertificateCreateWithData(nil, certificationData!)
let certificates: [SecCertificate] = [certificate!]
let evaluator = PinnedCertificatesTrustEvaluator.init(certificates: certificates)
let session = Session(configuration: configuration, serverTrustManager: ServerTrustManager(evaluators: ["api.iguoxiaodi.com": evaluator]))
return session
}
static let provider = MoyaProvider<MultiTarget>.init(endpointClosure: myEndpointClosure, requestClosure: requestClosure, session: pinningManager(), plugins: [LoadingPlugin])
ps:
https://fanthus.github.io/2022/08/30/ios-%E7%A6%81%E7%94%A8%E6%8A%93%E5%8C%85/
https://www.cnblogs.com/wenxp2006/p/9626730.html
https://github.com/Alamofire/Alamofire/issues/3039
网友评论