Open4

Charles,mitmproxyでアプリの通信を見る時の制限

はやぶさはやぶさ

Android

network_security_configのデフォルトの設定を適用している場合、通信を覗くことはできない。
charlesやmitmproxy用の証明書をデバイスにインストールしても、以下に書いてある理由で信頼されてないCA扱いとなるため。

https://developer.android.com/training/articles/security-config

デフォルトでは、すべてのアプリのセキュアな接続(TLS や HTTPS などのプロトコルを使用)は、システムにプリインストールされた CA を信頼し、Android 6.0(API レベル 23)以下を対象とするアプリは、ユーザーが追加した CA ストアも信頼します。

https://www.charlesproxy.com/documentation/using-charles/ssl-certificates/

As of Android N, you need to add configuration to your app in order to have it trust the SSL certificates generated by Charles SSL Proxying. This means that you can only use SSL Proxying with apps that you control.

はやぶさはやぶさ

iOS

iOSのApp Transport Security(ATS)のデフォルト設定では、上記のAndroidのような制限はなさそう。

但し証明書のピン留めをしている場合は不可。これはAndroidも同じ。
https://www.charlesproxy.com/documentation/faqs/ssl-proxying-with-ios-9/

Note that some apps implement SSL certificate pinning which means they specifically validate the root certificate, and will not work with Charles.

手元で見た感じtwitter, instagramは無理だった。証明書のピン留めを利用しているためだと思われる。

はやぶさはやぶさ

Flutter

現時点(Flutter 2.10.3)において、Flutter製アプリはシステムで設定したプロキシを無視する。
Charlesもmitmproxyも、ローカルに立てたプロキシサーバーを経由することで通信の覗き見をしているため、プロキシを無視するのであれば通信を覗き見することはできない。
以下のIssueを見る限り、アプリで明示的にプロキシサーバーを指定することは可能っぽい。

https://github.com/flutter/flutter/issues/20376
https://github.com/flutter/flutter/issues/26359