0
我試圖使用SSL將URL圖像下載到GMSTileLayer。NSURLSession/NSURLConnection嘗試使用Alamofire下載圖像時HTTP加載失敗
GMSTileLayer包含加載瓷磚到谷歌地圖層的委託方法:
override func requestTileFor(x: UInt, y: UInt, zoom: UInt, receiver: GMSTileReceiver) {
let url = URL(string: "\(urlPrefix)x=\(x)&y=\(y)&z=\(zoom)&is2d=t")
let zoom = UInt((self.map?.camera.zoom)!)
Alamofire.request(url!).responseImage { response in
if let image = response.result.value {
receiver.receiveTileWith(x: x, y: y, zoom: zoom, image: image)
}
}
}
當這個函數被調用時,我收到以下錯誤信息:
2017-06-22 09:55:49.192 PPGaugeApp[78556:4886424] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9801)
2017-06-22 09:55:49.274328-0400 PPGaugeApp[78556:4886488] [] nw_coretls_read_one_record tls_handshake_process: [-9801]
我已覈實通過在瀏覽器中測試,網址正在返回圖片。
在研究這個錯誤,幾乎所有的職位的建議作出一些改變的plist在包括minumum如下:
NSAllowsArbitraryLoads
我當前的plist設置如下:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>someDomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>
plist中沒有任何內容似乎對此錯誤消息有任何影響。我們的應用中的其他課程使用https進行身份驗證,但是這是我們通過https url下載文件的唯一地方。
還有其他地方我們應該檢查嗎?謝謝!