iOS 安全异常 (-9813) 仅来自 Kingfisher 库的调用

Tte*_*lle 1 security ios swift kingfisher

我收到这些错误

[] nw_coretls_callback_handshake_message_block_invoke_3 tls_handshake_continue: [-9812]
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
Run Code Online (Sandbox Code Playgroud)

当尝试从具有不受信任证书的 Web 服务加载图像时。我已经将我的项目 info.plist 配置为此, 并且它适用于对 Web 服务的“正常”请求。但一旦 Kingfisher-Lib 发出请求,我就会收到此错误。这是为什么?

Tte*_*lle 5

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)])
Run Code Online (Sandbox Code Playgroud)