4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NSAllowsArbitraryLoadsとNSAllowsArbitraryLoadsInWebContentの設定による挙動確認

Last updated at Posted at 2016-11-01

目的

  • ATS(App Transport Security)の挙動確認。
  • NSAllowsArbitraryLoadsとNSAllowsArbitraryLoadsInWebContentの設定による挙動をiOS9, iOS10で確認する。

環境

  • Xcode Version 8.1, Objective-C
  • iPhone5 10.0.2
  • iPhone7 Plus 10.1
  • iPhoneSE 9.3.2
  • iPhone6 8.2
    • iOS8の端末では関係無いとは思うが念のため確認。

準備

  • http:// でも https:// でもアクセスできるURLを用意
  • ATSに対応しているか確認(Macのターミナルで下記を実行)
    • nscurl --ats-diagnostics https://example.com

結果

  • 表示・データ取得できた場合を"◯", 表示・データ取得できなかった場合を"×"
  • NSAllowsArbitraryLoadsInWebContentの "-" は Info.plistに設定しないという意味
  • NSAllowsArbitraryLoadsInWebContentは表示の都合で省略

UIWebViewでの表示

https://example.com

NSAllowsArbitraryLoads NSAllows...InWebContent iOS8 iOS9 iOS10.0.2 iOS10.1
NO NO
NO YES
NO -
YES -
YES NO
YES YES

http://example.com

NSAllowsArbitraryLoads NSAllows...InWebContent iOS8 iOS9 iOS10.0.2 iOS10.1
NO NO × × ×
NO YES ×
NO - × × ×
YES -
YES NO × ×
YES YES

WKWebViewでの表示

https://example.com

NSAllowsArbitraryLoads NSAllows...InWebContent iOS8 iOS9 iOS10.0.2 iOS10.1
NO NO
NO YES
NO -
YES -
YES NO
YES YES

http://example.com

NSAllowsArbitraryLoads NSAllows...InWebContent iOS8 iOS9 iOS10.0.2 iOS10.1
NO NO × × ×
NO YES ×
NO - × × ×
YES -
YES NO × ×
YES YES

NSURLSession

https://example.com

NSAllowsArbitraryLoads NSAllows...InWebContent iOS8 iOS9 iOS10.0.2 iOS10.1
NO NO
NO YES
NO -
YES -
YES NO
YES YES

http://example.com

NSAllowsArbitraryLoads NSAllows...InWebContent iOS8 iOS9 iOS10.0.2 iOS10.1
NO NO × × ×
NO YES × × ×
NO - × × ×
YES -
YES NO × ×
YES YES × ×

注意しなければならないのはNSAllowsArbitraryLoadsInWebContentをInfo.plistに追加した時点でiOS10でNSURLSessionはhttpでの通信ができなくなるということ。
Exception Domainsを設定することで指定したドメインのみhttpで通信可能。

以上

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?