gpt4 book ai didi

swift - 本地开发站点上的 Alamofire SSL 错误

转载 作者:行者123 更新时间:2023-11-30 11:15:00 24 4
gpt4 key购买 nike

我正在尝试使用本地版本的 api 在本地计算机上开发一个应用程序,但当我运行 alamofire get request 时,我不断收到此错误。

[BoringSSL] Function nw_protocol_boringssl_input_finished: line 1436 Peer disconnected during the middle of a handshake. Sending errSSLFatalAlert(-9802) alert
2018-08-13 10:47:23.056793-0500 Edev[6851:453243] TIC TCP Conn Failed [1:0x60c000178480]: 3:-9802 Err(-9802)
2018-08-13 10:47:23.057251-0500 Edev[6851:453243] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
2018-08-13 10:47:23.057432-0500 Edev[6851:453243] Task <97194E8E-7E15-42EC-B8BA-534AC4E313A2>.<1> HTTP load failed (error code: -1200 [3:-9802])
2018-08-13 10:47:23.057686-0500 Edev[6851:453245] Task <97194E8E-7E15-42EC-B8BA-534AC4E313A2>.<1> finished with error - code: -1200
FAILURE: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9802, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x60400044f570 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9802, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://edev.test/edev, NSErrorFailingURLStringKey=https://edev.test/edev, _kCFStreamErrorDomainKey=3}
[BoringSSL] Function nw_protocol_boringssl_input_finished: line 1436 Peer disconnected during the middle of a handshake. Sending errSSLFatalAlert(-9802) alert
2018-08-13 10:47:23.056793-0500 Edev[6851:453243] TIC TCP Conn Failed [1:0x60c000178480]: 3:-9802 Err(-9802)
2018-08-13 10:47:23.057251-0500 Edev[6851:453243] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
2018-08-13 10:47:23.057432-0500 Edev[6851:453243] Task <97194E8E-7E15-42EC-B8BA-534AC4E313A2>.<1> HTTP load failed (error code: -1200 [3:-9802])
2018-08-13 10:47:23.057686-0500 Edev[6851:453245] Task <97194E8E-7E15-42EC-B8BA-534AC4E313A2>.<1> finished with error - code: -1200
FAILURE: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9802, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x60400044f570 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9802, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://edev.test/edev, NSErrorFailingURLStringKey=https://edev.test/edev, _kCFStreamErrorDomainKey=3}

这是我用来获取数据的 alamofire

Alamofire.request("https://edev.test/edev").responseJSON { response in
print(response)
print("Request: \(String(describing: response.request))") // original url request
print("Response: \(String(describing: response.response))") // http url response
print("Result: \(response.result)") // response serialization result

if let json = response.result.value {
print("JSON: \(json)") // serialized json response
}

if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
print("Data: \(utf8Text)") // original server data as UTF8 string
}
}

如果我的 plist 文件应该根据我在网上找到的内容成功运行,我已经设置了一个域异常(exception),但它仍然无法正常工作。

<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>edev.test</key>
<dict/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>

最佳答案

服务器有 SSL 证书吗?如果没有将 URL 更改为 Alamofire.request("http://edev.test/edev").responseJSON { 响应

关于swift - 本地开发站点上的 Alamofire SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51826298/

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