下面的代码总是返回零。
let url = NSURL(string: "https://s3.amazonaws.com/test-contentdelivery-mobilehub-462838928/tree.jpg")
let data = NSData(contentsOfURL: url!)
2015-10-31 16:25:16.795 test2[59798:19080494] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)url已经是https,aws s3提供了TLS1.2SSL。您可以在浏览器中尝试上述url,并检查证书和连接信息。看起来已经满足了ios 9的要求,但仍然没有数据。我不希望在Info.plist中设置“允许任意加载”=“是”。有什么想法吗?我漏掉了什么吗?是NSData(contentsOfURL: url!)使用http而不是https?
发布于 2015-10-31 21:05:18
AWS在他们的博客中写道,他们还没有准备好自动测试系统:https://mobile.awsblog.com/post/Tx2QM69ZE6BGTYX/Preparing-Your-Apps-for-iOS-9
他们建议在他们准备好之前定义一个选择退出的规则:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>amazonaws.com</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>amazonaws.com.cn</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>发布于 2015-10-31 21:06:38
在亚马逊准备就绪之前,您可以将以下内容放入您的info.plist中:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>amazonaws.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>https://stackoverflow.com/questions/33456425
复制相似问题