我正在尝试在我的应用中使用MapKit framework
。我需要获得路线积分。为此,我写了以下内容:
let directions = MKDirections(request: request)
directions.calculate { response, error in
if error != nil {
print("Error getting directions ", error.debugDescription)
} else {
guard let response = response else { return }
completion(response.routes[0])
}
}
但是,我收到错误消息:
错误获取路线说明可选(错误域= NSURLErrorDomain Code = -1202“此服务器的证书无效。您可能是 连接到假装为“ gsp-ssl.ls.apple.com”的服务器 这可能会使您的机密信息面临风险。” UserInfo = {NSErrorFailingURLKey = https://gsp-ssl.ls.apple.com/directions.arpc, NSLocalizedRecoverySuggestion =您是否要连接到服务器 无论如何?,NSUnderlyingError = 0x6000014bce40 {错误 Domain = kCFErrorDomainCFNetwork代码= -1202“(空)” UserInfo = {_ kCFStreamPropertySSLClientCertificateState = 0, _kCFNetworkCFStreamSSLErrorOriginalValue = -9843,_kCFStreamErrorDomainKey = 3,_kCFStreamErrorCodeKey = -9843,kCFStreamPropertySSLPeerCertificates =()}}, _kCFStreamErrorCodeKey = -9843,NSErrorPeerCertificateChainKey =(),NSLocalizedDescription =此服务器的证书无效。您 可能正在连接到假装为 “ gsp-ssl.ls.apple.com”可能会将您的机密信息 处于危险之中。NSErrorClientCertificateStateKey = 0, NSErrorFailingURLStringKey = https://gsp-ssl.ls.apple.com/directions.arpc, _kCFStreamErrorDomainKey = 3})
我已经编辑了Info.plist文件:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsLocalNetworking</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>gsp-ssl.ls.apple.com</key>
<dict>
<key>NSRequiresCertificateTransparency</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
答案 0 :(得分:-1)
向苹果报告错误后,该问题已解决,现在在不启用VPN的情况下一切正常。