Charles抓取https
阿新 • • 發佈:2019-01-10
1. 配置 Charles 根證書
開啟 Charles:
![](http://upload-images.jianshu.io/upload_images/1116587-80c49ff0b0e286c6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
主介面
然後如下圖操作:
![](http://upload-images.jianshu.io/upload_images/1116587-258b9fa545a210a4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
之後會彈出鑰匙串,如果不彈出,請自行開啟鑰匙串,如下圖:
![](http://upload-images.jianshu.io/upload_images/1116587-f9dee2972d918100.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
鑰匙串
系統預設是不信任 Charles 的證書的,此時對證書右鍵,在彈出的下拉選單中選擇『顯示簡介』,點選使用此證書時,把使用系統預設改為始終信任,如下圖:
![](http://upload-images.jianshu.io/upload_images/1116587-7869f742b0990853.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
然後關閉,就會發現 charles 的證書已經被信任了,如下圖:
![](http://upload-images.jianshu.io/upload_images/1116587-2f3a57dd4303f298.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2. 在移動裝置上配置證書
如下圖,選擇在移動裝置上安裝 Charles 根證書:
![](http://upload-images.jianshu.io/upload_images/1116587-07fdceeda33a03f2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
會彈出一個提示框,如下圖:
提示框
進入手機設定介面:
手機區域網設定
然後開啟手機的瀏覽器,輸入charlesproxy.com/getssl
![](http://upload-images.jianshu.io/upload_images/1116587-377cac0cd967fbf6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
安裝證書
點選安裝即可,如果出現的不是這個介面,那麼把連結換成https://www.charlesproxy.com/documentation/additional/legacy-ssl-proxying/
,點選安裝 itself 後面的 here 就可以了。
![](http://upload-images.jianshu.io/upload_images/1116587-10477f9cdd7b70b7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
此時還是獲取不到 https 的資料,各位童鞋不要著急,下面還有操作,接著還是進入 Charles ,如下圖操作:
![](http://upload-images.jianshu.io/upload_images/1116587-352cfcfe2fb78054.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
SSL Proxy Setting
如下圖,勾選Enable SSL Proxying
,點選新增,彈出下面的對話方塊,Host 表示你要抓取的 ip 地址或是連結,Port 填寫 443 即可:
![](http://upload-images.jianshu.io/upload_images/1116587-92d1a02e717a5846.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
設定
設定完成後,就可以抓取資料啦,如下圖:
![](http://upload-images.jianshu.io/upload_images/1116587-9ac87d11493b5e18.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
抓取資料
感謝hrscy