LoginSignup
1
0

More than 3 years have passed since last update.

Oculus Store 申請時の 'Enable Android NSC to Prevent Cleartext Traffic' という警告への対処方法

Last updated at Posted at 2019-10-20

追記

コメ欄で @shiena さんがよりスマートな対策方法を教えてくれました:bangbang: :bow:

Oculus Integration v1.41 以降は OVRManager の Security の
Enable NSC Configuration へチェックを入れるだけで対策出来そうでした :white_check_mark:
(全ての通信で HTTPS を強要されるため、アプリによっては後述の対策が必要になります)

基本的に Security の項目は Disable Backups も含めて
全てのチェックボックスをオンにしておいたほうが無難そうです :thumbsup: 1

スクリーンショット 2019-10-26 9.35.23.png

もし一部の通信では HTTP 通信を使いたい等、細かく通信周りの制御を行う必要がある場合は、
/Assets/Oculus/VR/Editor/network_sec_config.xml に該当ファイルが存在するので、
内容を書き換えることで NSC の詳細設定を行うことが可能です :arrow_down:

スクリーンショット 2019-10-26 9.43.14.png

NSC で設定可能な項目については、
ネットワーク セキュリティ構成 | Android Developers をご参照くださいませ :mag:

はじめに

Quest アプリを Oculus Store に提出する際に警告が出てきてしまいました。。:weary:
警告内容を見ると、ネットワークのセキュリティ設定に関するものでした :arrow_down:

The app has not enabled Android N's Network Security Configuration(https://developer.android.com/training/articles/security-config.html) feature, which forces the use of encryption (HTTPS) for all of the app's connections. The feature will block most cleartext HTTP traffic initiated by the app, which helps ensure that all data to and from the app has a base level of protection at all times.

対処方法を調べた所、
どうやら network_security_config.xml というファイルをプロジェクトに追加することで対策可能そうでした :thumbsup:

そこで、
今回は network_security_config.xml の追加手順 & 設定方法について書いていきます :pencil:

network_security_config.xml をプロジェクトに追加する

追加するフォルダは /Assets/Plugins/Android/res/xml になります :arrow_down:

/Assets/Plugins/Android/res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <!-- サブドメイン含む nikaera.com 以外のアクセスには HTTPS 通信が必須とする -->
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">nikaera.com</domain>
    </domain-config>
</network-security-config>

network_security_config.xml に記載する内容はプロジェクトによって異なると思いますが、
私の場合は特定ドメイン以外のアクセスには HTTPS 通信を必須とするよう設定しました :gear:

AndroidManifest.xml に network_security_config.xml を利用することを宣言する

プロジェクトに network_security_config.xml の内容を反映させるには、
AndroidManifest.xml に 1行設定に必要な記述を追加する必要あります :writing_hand:

/Assets/Plugins/Android/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest>
...
    <!-- android:networkSecurityConfig の設定を application タグに追加する -->
    <application
        android:networkSecurityConfig="@xml/network_security_config">
...
    </application>
...
</manifest>

AndroidManifest.xmlapplication タグに android:networkSecurityConfig 属性を追加し、
network_security_config.xml のファイルパスを指定することで設定が有効となります :white_check_mark:

この状態でビルドを行い APK の動作に問題が無いこと確認出来次第、
Oculus Store に再度アップロードしてみると、警告が無くなっていることが確認できるはずです :thumbsup:

おわりに

今回は Enable Android NSC to Prevent Cleartext Traffic の対処法について紹介しました :hand_splayed:

実は他にも警告が出ているのですが、どうやらどれも Android に関わるもののようで、
Oculus Store 申請時は、「ココらへんも気をつけないといけないんだなあ」と思いました。。 :skull:

参考リンク


  1. AndroidManifest.xml の allowBackup 項目に false が設定されるようになり、APK アップロード時の警告を更に 1つ減らすことが出来ます :thumbsup:  

1
0
4

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
1
0