我有多个来自 imgur 的 HTTPS 链接(例如https://i.stack.imgur.com/9nSMi.jpg https://i.stack.imgur.com/9nSMi.jpg)。我使用它作为我的原型应用程序的背景之一,但每当我在 iPhone 7 物理设备上运行它时,应用程序就会崩溃并显示错误代码 1200。实际错误如下:
2019-01-22 19:36:54.402391+0800 App[00000:0000000] Task <00000000000000000000>.<2> load failed with error Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://i.stack.imgur.com/9nSMi.jpg, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <00000000000000000>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <0000000000000>.<2>"), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://i.stack.imgur.com/9nSMi.jpg, NSUnderlyingError=0x2824d4150 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9816, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9816}}, _kCFStreamErrorCodeKey=-9816} [-1200]
用于检索 url 的代码:
let imgURL = URL(string: "https://i.stack.imgur.com/9nSMi.jpg")
let imgImageView = UIImageView()
imgImageView.kf.setImage(with: imgURL) { (img, err, cacheType, url) in
if img == nil {
// TODO: add placeholder image when url didn't loaded
}
let imgTexture = SKTexture(image: img!)
self.img = SKSpriteNode(texture: imgTexture)
}
我不想关闭应用程序传输安全性,因为我不想可能破坏 Apple 在 Xcode 中开发的应用程序的安全性