简体   繁体   English

UIWebview无法在iOS9中加载URL

[英]UIWebview not load URL in ios9

i want to load url in web view like as 我想像这样在网络视图中加载URL

NSString *urlAddress = @"http://ashu007blr.tumblr.com/loadadd";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[self.adWeb loadRequest:requestObj];

but i get error like as 但我得到像这样的错误

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

i find solution for google then i added NSAppTransportSecurity in my info.plist like as 我找到了谷歌的解决方案,然后我在我的info.plist添加了NSAppTransportSecurity ,如下所示

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

but it is not working i get same error. 但它不起作用,我得到同样的错误。

Did you do this? 你做了这个了吗?

Open your info.plist file like this picture 像这样打开您的info.plist文件

http://imgur.com/mVvKD1R http://imgur.com/mVvKD1R

And add the following two attributes 并添加以下两个属性

  1. NSAppTransportSecurity NSAppTransportSecurity

  2. NSAllowsArbitraryLoads NSAllowsArbitraryLoads

Note: 1st one is NSDictionary type and second one is BOOL Type 注意:第一个是NSDictionary类型,第二个是BOOL类型

This occurs for HTTPS connections to servers that don't have the appropriate setup for Perfect Forward Secrecy. 对于没有正确设置Perfect Forward Secrecy的服务器的HTTPS连接,会发生这种情况。

See Apple's Tech Note which lists the requirements. 请参阅Apple的技术说明 ,其中列出了要求。

Our own server https://prod.ly needed a new SSL certificate, namely one with SHA256 signature. 我们自己的服务器https://prod.ly需要一个新的SSL证书,即带有SHA256签名的SSL证书。 It was still using an older, less secure, algorithm. 它仍在使用较旧的,不太安全的算法。

These are the App Transport Security requirements: 这些是应用程序传输安全性要求:

  1. The server must support at least Transport Layer Security (TLS) protocol version 1.2. 服务器必须至少支持传输层安全性(TLS)协议版本1.2。
  2. Connection ciphers are limited to those that provide forward secrecy (see the list of ciphers below.) 连接密码仅限于提供前向保密性的密码(请参阅下面的密码列表)。
  3. Certificates must be signed using a SHA256 or better signature hash algorithm, with either a 2048 bit or greater RSA key or a 256 bit or greater Elliptic-Curve (ECC) key. 证书必须使用SHA256或更好的签名哈希算法进行签名,并使用2048位或更高的RSA密钥或256位或更高的椭圆曲线(ECC)密钥。
  4. Invalid certificates result in a hard failure and no connection. 无效的证书会导致严重故障并且无法连接。

These are the accepted ciphers: 这些是公认的密码:

  • TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
  • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
  • TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA

PS: You can check your server's suitability for ATS/PFC with the SSL Labs checker page: eg https://www.ssllabs.com/ssltest/analyze.html?d=api.productlayer.com PS:您可以通过SSL Labs检查器页面检查服务器对ATS / PFC的适用性:例如https://www.ssllabs.com/ssltest/analyze.html?d=api.productlayer.com

PPS: Your original URL might be HTTP, but there are several resources referenced from the HTML that comes back that are accessed via HTTPS, eg https://secure.assets.tumblr.com PPS:您的原始URL可能是HTTP,但是从HTML返回的引用的一些资源可以通过HTTPS访问,例如https://secure.assets.tumblr.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM