HTTPS抓包时, 如果应用不信任用户证书, 需要把证书安装为系统证书.
如果证书为二进制格式(cer, der), 需要先转换为文本格式
$ openssl x509 -inform der -in cert.cer -outform pem -out cert.pem
获取hash, 存为$CERT_HASH
$ CERT_HASH=`openssl x509 -inform pem -in cert.pem -subject_hash_old | head -1`
制作证书文件
$ cp cert.pem ${CERT_HASH}.0
$ openssl x509 -inform pem -in cert.pem -text -noout >> ${CERT_HASH}.0
push到设备中
$ adb root
$ adb remount
$ adb push ${CERT_HASH}.0 /system/etc/security/cacerts/
更改权限
$ adb shell chmod 644 /system/etc/security/cacerts/${CERT_HASH}.0
如果Android13以上无法remount, 可以尝试
1 | $ adb shell setprop sys.debug.allow_remount true |
或者使用overlayfs
1 | $ adb shell |
或者使用mount --bind
1 | $ adb shell |