Http 请求 iOS 11.2 失败

Http Request iOS 11.2 failes

我尝试向我的服务器发出 http 请求以获取 JSON,但每次尝试时我都会收到此错误消息。

2018-03-26 16:53:32.477431+0200 S_Buddy[40041:3435695] [] nw_socket_connect connect failed (fd 8, 172.227.96.127:443 stream, pid: 40041, sanitized url: https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml, tls): [64] Host is down 2018-03-26 16:53:32.479737+0200 S_Buddy[40041:3435695] TIC TCP Conn Failed [1:0x60400017f5c0]: 3:64 Err(64) 2018-03-26 16:53:32.480346+0200 S_Buddy[40041:3435695] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, 64) 2018-03-26 16:53:32.480465+0200 S_Buddy[40041:3435695] Task <2DA19979-F9F3-4F4B-92EB-AF8BE012833F>.<1> HTTP load failed (error code: -1200 [3:64]) 2018-03-26 16:53:32.480970+0200 S_Buddy[40041:3435696] Task <2DA19979-F9F3-4F4B-92EB-AF8BE012833F>.<1> finished with error - code: -1200 Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=64, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x60000044cae0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=64, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=64}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml?c9911b4d481e6ada019ba2d93f6cf780, NSErrorFailingURLStringKey=https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml?c9911b4d481e6ada019ba2d93f6cf780, _kCFStreamErrorDomainKey=3}

我的info.plist配置是:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>ecb.europa.eu</key>
        <dict>
            <key>NSIncludesSubdomains</key>
                <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            <key>NSTemporaryExceptionMinimumTSLVersion</key>
                <string>TLSv1.0</string>
            <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
                <false/>
        </dict>
    </dict>
</dict>

我的 iOS 目标是 10,我使用 Swift 4

我从网络上的类似问题中发现,他们使用了以下键,包括一些与您已经在使用的键不同的键:

<key>NSExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSRequiresCertificateTransparency</key>
<false/>                
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>

<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<true/>

我还没有在你的特定网站上测试过这个。