我有一个在Laravel Homestead上运行的本地服务器:
https://laravel.com/docs/5.3/homestead
Homestead预先包装有SSL证书,我通过HTTPS发出所有请求。但是,当尝试从我的iOS应用发出请求时,出现以下错误:
ATS failed system trust
Connection 3: system TLS Trust evaluation failed(-9802)
Connection 3: TLS Trust encountered error 3:-9802
Connection 3: encountered error(3:-9802)
Task <892C4896-1D02-4465-AF06-D7534BE39828>.<1> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9802])
Task <892C4896-1D02-4465-AF06-D7534BE39828>.<1> finished with error [-1200] Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=(
"<cert(0x7fc76e82d800) s: mydomain.test i: Homestead homestead Root CA>"
)
我已将以下内容添加到我的Info.plist中:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
在阅读了有关通过Alamofire和Moya进行SSL固定的文章和Github问题之后,我还做了以下事情:
let evaluators: [String: ServerTrustEvaluating] = [
"mydomain.test": DisabledEvaluator()
]
let manager = ServerTrustManager(evaluators: evaluators)
let session = Session(serverTrustManager: manager)
let provider = MoyaProvider<T>(session: session, plugins: [NetworkLoggerPlugin(verbose: true)])
我还在Mac上安装了证书,并将其设置为“ Always Trust”,但是在运行iOS应用程序时仍然出现错误。
我在做什么错?我想念什么?
答案 0 :(得分:0)
这是我的解决方案,可能无法完成您的问题。 我不使用url作为“ myweb.local”。我在开发中使用直接IP和更改应用程序的端口。使用端口时,不需要SSL。 示例:
127.0.0.1:8000