Recent work requires network packet capture for the app. I installed the fiddler tool and used the Yeshen simulator to simulate mobile phone packet capture. All configurations have been configured, but the app still cannot connect to the Internet. The solution is recorded as follows:
【problem causes】
When we install the fiddler certificate on the phone or simulator, the certificate is installed in the user certificate directory. Applications after Android 7.0 only trust the system certificate by default and do not trust the user certificate, so we have two methods. solve this problem. 1. Install the Fiddler certificate into the system certificate directory and disguise it as a system certificate. 2. Use Android 5.0 version mobile phone or simulator. Use the first method below.
1. Export fiddler certificate
1. Before doing this, please make sure that your fiddler has been installed and configured!
2. First close fiddler, then download the fiddlercertmaker.exe tool, double-click the downloaded fiddlercertmaker.exe (make sure Fiddler is closed), a dialog box will pop up prompting that the certificate import was successful, click OK
3. Export the fiddler certificate to the computer desktop, Tools -> Options -> HTTPS -> Actions -> Export Root Certificate to Desktop
After completion, a FiddlerRoot.cer certificate will appear on the computer desktop.
2. Install openssl
1. Go to the openssl download address to download the windows version of openssl.
2. Click Install and click Next
3. After the installation is completed, you need to configure the environment variables . Configure the bin directory of the installation directory to the environment variables.
4. Open the terminal and enter openssl version
or enter and openssl
the following message will appear, indicating that the installation is successful.
3. Certificate format conversion
1. Convert the Fiddler cer
certificate to pem
a certificate and enter the following command in cmd:openssl x509 -inform DER -in 电脑桌面证书路径.cer -out 电脑桌面证书路径.pem
openssl x509 -inform DER -in C:\Users\Administrator\Desktop\FiddlerRoot.cer -out C:\Users\Administrator\Desktop\FiddlerRoot.pem
2. To calculate the value pem
of the certificate hash
, enter the following command:openssl x509 -inform PEM -subject_hash_old -in 电脑桌面证书路径
openssl x509 -inform PEM -subject_hash_old -in C:\Users\Administrator\Desktop\FiddlerRoot.pem
The picture above e5c3944b
is pem
the hash value of the certificate.
3. Use the following command e5c3944b
to pem
rename the certificate:ren 电脑桌面证书路径 证书hash值.0
ren C:\Users\Administrator\Desktop\FiddlerRoot.pem e5c3944b.0
4. Install the certificate to the system directory
Here I am using the Night God simulator
1. Open the terminal input adb connect 127.0.0.1:62001
and connect to the Yeshen simulator (if it appears, 'adb' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
you need to find the platform-tools path under the SDK installation path and enter cmd to open the terminal)
2. cmd input adb shell
3, cmd input cd /system/etc/security
,
4. cmd input ls -l
view permission, this does not have write permission
5. Enter cmd. chmod 777 cacerts
Now you have write permissions on the directory. You can enter the old permissions again ls -l
to view the directory permissions.
Now you have write permissions.
If the input chmod 777 cacerts
"Read-only file system" appears and
you need to remount the system, enter mount -o remount,rw /system
it again chmod 777 cacerts
and it will be successful.
6. Enter cmd to exit
exit the shell terminal, then enter adb push C:\Users\Administrator\Desktop\e5c3944b.0 /system/etc/security/cacerts, and push the pre-converted Fiddler certificate to /system/ of the Yeshen simulator. In the etc/security/cacerts directory,
the fiddler certificate has been installed in the system certificate directory of the simulator. Open the Yeshen simulator.
You're done! You can see that the fiddler certificate has been installed in the system directory.
Make sure that the simulator has set up the proxy IP and port. At this time, open fiddler to capture the simulator's package and there will be no problem of no network.
Finally, special thanks! Detailed tutorial on Android 7.0+ emulator Fiddler packet capture