gpt4 book ai didi

ios - 应用程序传输安全 : NSURLSession/NSURLConnection HTTP load failed

转载 作者:可可西里 更新时间:2023-11-01 01:03:29 24 4
gpt4 key购买 nike

我有这个代码:

func loginWithBasicAuth() -> Void {

let usernameText = username.text
let passwordText = password.text

let credentialData = "\(usernameText):\(passwordText)".dataUsingEncoding(NSUTF8StringEncoding)
let base64Credentials = credentialData?.base64EncodedStringWithOptions([])
let headers = ["Authorization": "HTTP Basic \(base64Credentials)"]

Alamofire.request(.GET, "https://api.domainname.com/v0.1/", headers: headers).responseString { aResponse in

if let receivedString = aResponse.result.value {

print(receivedString)

} else {

print("Login failed.")

}
}
}

在控制台中打印:

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) Login failed.

info.plist文件中的配置如下: enter image description here

怎么了?

最佳答案

我不确定 NSThirdPartyExceptionAllowsInsecureHTTPLoads 是通过 HTTPS 连接时使用的正确 key 。您可能应该使用 NSThirdPartyExceptionMinimumTLSVersionNSThirdPartyExceptionRequiresForwardSecrecy

我强烈推荐阅读 App Transport Security Technote文档,特别是诊断连接问题部分。

有一个工具可以帮助您诊断您的域:

/usr/bin/nscurl --ats-diagnostics [--verbose] URL

关于ios - 应用程序传输安全 : NSURLSession/NSURLConnection HTTP load failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33238037/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com