LoginSignup
26
25

More than 5 years have passed since last update.

【iOS9】Amazon S3のHTTPSを対応させる方法

Posted at

現象

iOS9では、アプリで基本SSLに対応していない通信は弾かれてしまいます。

iOS9 ATS問題

Apple公式は下記から
App Transport Security Technote

S3の対応について

Amazon S3を使って画像やJSONファイルを読み込ませるために使っており、iOS9で検証したところ、HTTPでの通信で弾かれることに気づきました。

で、HTTPSにURLを変更したところ、通らない。。。

S3のSSLが、Appleの対応のもに合わないため、通信は通らないようです。

S3側の対応は、9月30日まで対応するそうです。

SHA256ハッシュアルゴリズムへの対応

アプリで通信を通るようにする方法

S3の対応を待っていられない方は、Xcodeプロジェクトに設定を入れて対応しましょう。

Custom iOS Target Propertiesに
App Transport Securityに関する記述をすることで解決します。

Info.plistに下記を記述

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>s3-ap-northeast-1.amazonaws.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
        </dict>
    </dict>

NSIncludesSubdomainsを設定することで、サブドメインを有効にできます。
セキュリティをより厳しくするのであれは、NSIncludesSubdomainsのKey/Valueを外し、${bucketName}.s3-ap-northeast-1.amazonaws.comなどのフルのホスト名で記述しましょう。

各種設定項目は、App Transport Security Technoteに記載されています。

26
25
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
26
25