【问题标题】:iOS Security Exception (-9813) only from calls of Kingfisher LibraryiOS 安全异常 (-9813) 仅来自 Kingfisher 库的调用
【发布时间】:2017-08-16 06:34:21
【问题描述】:
我收到这些错误
[] nw_coretls_callback_handshake_message_block_invoke_3 tls_handshake_continue: [-9812]
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
尝试从具有不受信任证书的 Web 服务加载图像时。我已经将我的项目 info.plist 配置为
this 它确实适用于对 Web 服务的“正常”请求。但是一旦 Kingfisher-Lib 提出请求,我就会收到此错误。这是为什么?
【问题讨论】:
标签:
ios
swift
security
kingfisher
【解决方案1】:
Kingfisher 似乎使用自定义方式来访问 url。解决方案是手动将主机配置为在下载器中受信任:
let downloader = KingfisherManager.shared.downloader //Downloader needs to be configured to accept untrusted certificates
downloader.trustedHosts = Set(["your_untrusted_certificate_host"])
imageView.kf.setImage(with: URL(string: "\(applicationSession.environment.systemUrl!)\(path)"), placeholder: #imageLiteral(resourceName: "noImageImage"), options: [.requestModifier(modifier), .downloader(downloader)])