gpt4 book ai didi

ios - 在 iOS 10 的 swift 3 中进行休息调用时出错

转载 作者:行者123 更新时间:2023-11-28 16:05:50 24 4
gpt4 key购买 nike

let url string = "https://myURL"

func task(_ urlstring: String,json: AnyObject, ComplitionHandler: @escaping taskCompletionHandler )
{
do
{
let jsonData = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted)
let url = URL(string: urlstring)
var request = URLRequest(url: url!)
request.httpMethod = "POST"
request.httpBody = jsonData
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

let task = URLSession.shared.dataTask(with: request, completionHandler: {(data,response,error) in

if(error != nil)
{
print(error)
ComplitionHandler(nil, nil )
return
}
ComplitionHandler(data!, response!)
})
task.resume()
}
catch
{
print("error")
}
}

我在 .plist 中添加了一些更改(应用程序传输安全,允许任意加载=YES,允许 Web 内容中的任意加载=YES)

但仍然出现以下错误:

NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://myurl, NSErrorFailingURLStringKey=https://myurl, NSErrorClientCertificateStateKey=0

最佳答案

好吧,受信任的根证书列表已在 iOS 10 上更新,因此判断您应该确保您的 SSL 证书不是 iOS 10 阻止的根证书的一部分。

Updated List

如果您有 WoSign CA 免费 SSL 证书 G2,Apple 会阻止它,因为他们声称它有多个控制故障。更多信息 here

关于ios - 在 iOS 10 的 swift 3 中进行休息调用时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40304043/

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