iOS9でHTTP通信がSSL通信になるのを防ぐ方法
iOS9でNSURLRequestが強制的にSSL通信になるのを防ぐ方法
Error Domain=NSURLErrorDomain Code=-999 “The operation couldn’t be completed. (NSURLErrorDomain error -999.)” UserInfo=0x17eafe00 {NSErrorFailingURLKey=http://nlogic.jp, NSErrorFailingURLStringKey=http://nlogic.jp}
こんなコードを書くと
|
1 |
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://nlogic.jp/"]]]; |
こんなログになる。。。
|
1 2 3 4 5 6 |
shouldStartLoadWithRequest url: http://nlogic.jp/ shouldStartLoadWithRequest url: https://nlogic.jp/ shouldStartLoadWithRequest url: http://nlogic.jp/ didFailLoadWithError error: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x14e989f0 {NSErrorFailingURLKey=http://nlogic.jp/, NSErrorFailingURLStringKey=http://nlogic.jp/} shouldStartLoadWithRequest url: https://nlogic.jp/ NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) |
なんか強制的にSSL通信になってるんだけど。
回避方法
アプリのinfo.plistに下記を追加する。
|
1 2 3 4 5 |
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> |
とりあえず回避できた。
|
1 2 3 |
shouldStartLoadWithRequest url: http://nlogic.jp/ shouldStartLoadWithRequest url: http://nlogic.jp/ didFailLoadWithError error: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x17ec32b0 {NSErrorFailingURLKey=http://nlogic.jp/, NSErrorFailingURLStringKey=http://nlogic.jp/} |
スポンサーリンク