monkeyWie / proxyee

HTTP proxy server,support HTTPS&websocket.MITM impl,intercept and tamper HTTPS traffic.
MIT License
1.51k stars 566 forks source link

自己生成的证书问题 #162

Closed effectda closed 3 years ago

effectda commented 3 years ago

key的生成,这样是生成RSA密钥,openssl格式,2048位强度。ca.key是密钥文件名。

openssl genrsa -out ca.key 2048

key的转换,转换成netty支持私钥编码格式

openssl rsa -in ca.key -out ca_private.der -outform der

crt的生成,通过-subj选项可以自定义证书的相关信息

openssl req -sha256 -new -x509 -days 365 -key ca.key -out ca.crt \ -subj "/C=CN/ST=GD/L=SZ/O=lee/OU=study/CN=testRoot" 生成完之后把ca.crt和ca_private.der复制到项目的 src/resources/中,或者实现 HttpProxyCACertFactory 接口来自定义加载根证书和私钥

通过这些命令生成证书,也把文件移动到手机 /system/etc/security/cacerts/ 并给与644权限了,但是没法拦截https请求?什么原因呢

monkeyWie commented 3 years ago

先在pc上试试

effectda commented 3 years ago

pc上也不拦截https ,程序默认的证书可以拦截到https

monkeyWie commented 3 years ago

生成好证书之后放哪了呢

effectda commented 3 years ago

resources下

monkeyWie commented 3 years ago

代码设置了handleSsl(true)吗,还有点就是根证书安装了没有

effectda commented 3 years ago

代码设置了,根证书也安装了

monkeyWie commented 3 years ago

把私钥和证书上传上来我试试看

effectda commented 3 years ago

证书.zip

monkeyWie commented 3 years ago

文档写的有问题,用这个命令转化下私钥就行了:

openssl pkcs8 -topk8 -nocrypt -inform PEM -outform DER -in ca.key -out ca_private.der
effectda commented 3 years ago

可以拦截https了但是证书不受信任,已经在chrome里导入受信任的证书了

monkeyWie commented 3 years ago

一定要安装在受信任的根证书颁发目录下才行 image

effectda commented 3 years ago

是安装在这里的

monkeyWie commented 3 years ago

把证书和私钥再发我试试

effectda commented 3 years ago

证书.zip

monkeyWie commented 3 years ago

我试了下没问题啊,你看看浏览器上那个证书对不对 image image

effectda commented 3 years ago

证书不对,好像直接把证书放在resources目录下有点问题,我通过caCertFactory方法设置证书可以了 ,谢谢您耐心的回复

monkeyWie commented 3 years ago

不客气,估计是加载到默认的证书了