LoginSignup
22
17

More than 5 years have passed since last update.

Android 7 以降で mitmproxy が動作しない

Last updated at Posted at 2017-05-10

原因

Android 7 (API Level 24) からセキュリティポリシーが変わり Chrome と Webview 以外についてはユーザーが登録した証明書を受け付けない仕様になったそうです。

対処方法

自分のアプリで受け付けるようにするにはネットワーク・セキュリティの設定をアプリに追加する必要があるようです。

1. ネットワーク・セキュリティの設定を記述した xml を作る

以下の xml を app/src/main/res/xml に作成します。ここでは network_security_config.xml とします。この設定は <debug-overrides>に囲まれているので、デバッグビルドのときにしか反映されないことに注意です。

<network-security-config>  
     <debug-overrides>  
          <trust-anchors>  
               <!-- Additionally trust user added CAs -->  
               <certificates src="user" />  
          </trust-anchors>  
     </debug-overrides>  
</network-security-config>

2. network_security_config.xml を AndroidManifest.xml から読み込まれるようにする

AndroidManifest.xml のApplication タグのところに android:networkSecurityConfig の設定を記述します。

<application
        android:name=".OrenoApp"
        android:networkSecurityConfig="@xml/network_security_config"
        >
        ...
</application>

3. これでビルドして試せばうまくいくはず

参考情報等

22
17
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
22
17