以这种方式使用Alamofire来解决问题:
let serverTrustPolicies: [String: ServerTrustPolicy] = [
"localhost": .PinCertificates(
certificates: ServerTrustPolicy.certificatesInBundle(),
validateCertificateChain: true,
validateHost: true
)]
let configue = NSURLSessionConfiguration.defaultSessionConfiguration()
configue.HTTPAdditionalHeaders = Manager.defaultHTTPHeaders
mrg = Manager(
configuration: configue,
serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies))
mrg!.request(.GET, "https://localhost/Demo/products.php", parameters: nil, encoding: .URL, headers: nil).responseJSON {
guard let res = $0.result.value where res is NSArray else { print("error"); return; }
self.json = JSON(res)
}
然后错误域= NSURLErrorDomain代码= -999"取消"。
它是如何发生的?哪里错了?
alamofire源代码没有任何变化。
谢谢你的回答!