2
我正在使用Alamofire并尝试从我的服务器获取JSON Feed。服务器具有自签名证书和通过用户和密码访问。Alamofire 4 - Swift 3 - 全权证书和自签名证书
这里是我的代码
let user = "user"
let password = "password"
let url1 = "https://10.0.1.2:4711/fhem/?cmd=jsonlist2&XHR=1"
let credential = URLCredential(user: user, password: password, persistence: .forSession)
let serverTrustPolicies :[String: ServerTrustPolicy] = [
"10.0.1.8": .disableEvaluation
]
let AlamoSession = SessionManager(serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies))
AlamoSession.request(url1)
.authenticate(usingCredential: credential)
.responseJSON { response in
debugPrint(response.response)
print("Result value \(response.result.value)")
//print (response.result.value?.valueForKey("status"))
}
但它确实也没有工作!
我该怎么做?
在https地址上发出获取请求wir自签名证书?
在我的应用程序中的info.plist我添加了 应用交通运输安全设置 - 允许任意负载 - YES