【问题标题】:The NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) errorNSURLSession/NSURLConnection HTTP 加载失败 (kCFStreamErrorDomainSSL, -9802) 错误
【发布时间】:2015-10-23 16:28:02
【问题描述】:

我试图通过下面的代码将 URL 加载到 webview 中,每次我尝试 loadRequest 时,它都会失败并出现上述错误。

@IBOutlet weak var wb: UIWebView!
func openCheckoutPage(landingUrl:String,token:String)
{
        let url:String = "\(landingUrl)&token=\(token)"
        self.wb.loadRequest(NSURLRequest(URL: NSURL(string: url)!))
}

请记住,我已经在 info.plist 中添加了适当的 NSAppTransportSecurity 密钥

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <false/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>walgreens.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSAllowsArbitraryLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>

【问题讨论】:

    标签: ios swift uiwebview


    【解决方案1】:

    问题在于,作为加载该 URL 的一部分,我们需要加载 包含在 walgreens.com 下的其他 URL。但是您已经关闭了任意加载,因此它们无法加载。

    【讨论】:

    • 将 NSAllowsArbitraryLoads 的键设置为 true 仍然会引发错误
    • 好吧,也许这只是一个错误的 URL、糟糕的服务器等等。我不知道你的 URL 是什么或那里有什么。你在桌面的 Safari 中试过吗?
    • 该网址在桌面上加载正常,它显示的唯一错误是imgur.com/bdd95wR
    • 令人着迷。这真的是问题吗?
    • 也许吧?我不知道这就是我问的原因哈哈
    猜你喜欢
    • 2015-09-04
    • 2016-01-03
    • 1970-01-01
    • 1970-01-01
    • 2017-06-10
    • 2015-11-19
    • 2015-12-29
    • 2016-01-18
    • 1970-01-01
    相关资源
    最近更新 更多