报错为 NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9824)
还有这个错误 CFNetwork SSLHandshake failed (-9824)
代码如下
NSURL *url = [NSURL URLWithString:@"https://booking.cn.fcm.travel/img/200049324/144799957714318319/20151120140610983315.png"];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
UIImageView *image1 = [[UIImageView alloc] init];
image1.frame= CGRectMake(10, 10, 100, 100);
image1.image=image;
[self.view addSubview:image1];
下面的操作是不管用的
info.plist加上这一段,右键 info.plist -> open as -> source code
用代码加
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Buy an SSL certificate. Customized ones will not pass. Please refer to the evil 12306.
Currently WoSign’s free SSL cannot pass Android and IOS certification.
Use a paid one, just use the cheapest RapidSSL. Dozens of dollars a year.
Try upgrading to xcode7.1, there is an option YES. . . .
AppDelegate.m
If it is XCODE 7 or above version, plist needs to be added
1. Self-signed certificates are not trusted. You can implement conection proxy and ignore the certificate, which is more troublesome to implement.
2. Your server should be set to only support https requests. You can set it to support two protocols at the same time
You can replace the self-signed SSL certificate with a free SSL certificate trusted by browsers, such as startssl, WoSign free SSL, let us encrypt