wuchangming / node-mitmproxy

node-mitmproxy is an extensible man-in-the-middle(MITM) proxy server for HTTP/HTTPS base on Node.js.
MIT License
280 stars 62 forks source link

关于node-mitmproxy在Android手机端访问https的问题 #13

Open zimo2013 opened 6 years ago

zimo2013 commented 6 years ago

http没有问题,部分https返回正常,但部分https会报错,错误如下

(node:19245) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Cannot read public key. OID is not RSA.

//js 配置如下 sslConnectInterceptor: (req, cltSocket, head) => true, caCertPath: '/Users/mac/node-mitmproxy/node-mitmproxy.ca.crt', caKeyPath: '/Users/mac/node-mitmproxy/node-mitmproxy.ca.key.pem',

Android手机已经安装了对应的证书crt

wuchangming commented 6 years ago

@stackzhang ,会报错的https请求不用代理时用浏览器能否正常打开?

zimo2013 commented 6 years ago

@wuchangming 源生App里嵌套一个网页,这个网页中会有ajax网络请求,这个请求是https的,不知道是否可以拦截到。 我使用charles是看到了这个请求

我的需求,就是使用代理,获取部分接口的数据(http/https的),不修改任何数据。

wuchangming commented 6 years ago

@stackzhang ,是可以拦截的。 一些比较简单的拦截配置,可以参考: 拦截请求:https://github.com/wuchangming/node-mitmproxy/blob/master/example/config/requestInterceptorConfig.js 拦截响应: https://github.com/wuchangming/node-mitmproxy/blob/master/example/config/responseInterceptorConfig.js