環(huán)境:Mac電腦,安卓手機
抓不到數(shù)據(jù)大致三個問題:
1、android7.0以后需要在代碼里添加設(shè)置
2、Mac下載了SSL證書別忘了右鍵設(shè)置“信任”
3、Okhttp是否設(shè)置了禁止代理模式NO_PROXY
-------------------------------------------------------------------------------------------------------------------------------------------
1、手機設(shè)置代理:
檢查電腦ip地址,查看chrales端口號,或者點擊 Help 》 SSL Proxying 》Install Charles Root Certificate on a Mobile Device or Remote Breoser查看;

在手機WLAN設(shè)置中設(shè)置手動代理,輸入ip和端口號。
2、安裝電腦端SSL證書:
點擊 Help 》 SSL Proxying 》 Install Charles Root Certificate
下載完別忘了 右鍵? ? ——信任
3、安裝手機端SSL證書:
在這之前必須已經(jīng)設(shè)置好代理,
點擊 Help 》 SSL Proxying 》Install Charles Root Certificate on a Mobile Device or Remote Breoser,按照要求在瀏覽器輸入 chls.pro/ssl會直接下載,然后再WLAN設(shè)置中 找到從手機存儲中安裝證書,安裝之!
4、看看結(jié)果:
運行項目,發(fā)現(xiàn)雖然攔截到了,但是看不到contents內(nèi)容,Overview欄提示“Client SSL handshake failed: An unknown issue occurred processing the certificate”、“You may need to configure your browser or application to trust the Charles Root Certificate. See SSL Proxying in the Help menu.”原因是安卓7以后不讓這么干了。
5、把手機證書添加到系統(tǒng)級別:
https://blog.csdn.net/ShadowySpirits/article/details/79756274
手機上是否有裝證書都可以使用下面的方法:

6、如果還是抓不到任何包,看看是否是Retrofit設(shè)置了禁止代理:
