LoginSignup
4
3

More than 5 years have passed since last update.

Android OS 7 以上で Charles を使う

Last updated at Posted at 2019-04-04

はじめに

社内のAndroid端末で Charles を使ったときのメモ。
Android OS 7 以上では、 SSL通信(https)を割り込むのに、以下の設定が必要だった。

Charlesについては割愛。

環境

Android OS 8.0.0
macOS High Sierra 10.13.6

証明書の書き出し

Help -> SSL Proxying -> Save Charles Root Certificate...
1.png

適当に certificate.pem で保存。

アプリの設定

  1. 書き出したファイルを追加

    rawフォルダが無ければ作成する。

/app/src/main/res/raw/certificate.pem



2. 設定ファイルを作成。

    格納場所は `/app/src/main/res/xml` 配下。
    ファイル名は適当に `network_security_config.xml` とする。

    ```xml:/app/src/main/res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config>
        <trust-anchors>
            <certificates src="system"/>
        </trust-anchors>
    </base-config>
    <debug-overrides>
        <trust-anchors>
            <certificates src="@raw/certificate"/> ← さっき作成したファイル
        </trust-anchors>
    </debug-overrides>
</network-security-config>
  1. AndroidManifest.xmlに1行追加

    AndroidManifest.xml
    <application
        android:networkSecurityConfig="@xml/network_security_config"   追加
    

以上。
4
3
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
3