From b5764c8ee9f985ce0cb07b97b9b29cd74973585f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Sun, 29 Sep 2024 23:58:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0SSL=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0=E5=B9=B6=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/mitmproxy/src/lib/proxy/common/util.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/mitmproxy/src/lib/proxy/common/util.js b/packages/mitmproxy/src/lib/proxy/common/util.js index 9335ae6..1a0f04a 100644 --- a/packages/mitmproxy/src/lib/proxy/common/util.js +++ b/packages/mitmproxy/src/lib/proxy/common/util.js @@ -29,10 +29,16 @@ function createHttpsAgent (timeoutConfig, verifySsl) { if (!httpsAgentCache[key]) { verifySsl = !!verifySsl + // 证书回调函数 + const checkServerIdentity = (host, cert) => { + log.info(`checkServerIdentity: ${host}, CN: ${cert.subject.CN}, C: ${cert.subject.C || cert.issuer.C}, ST: ${cert.subject.ST || cert.issuer.ST}, bits: ${cert.bits}`) + } + const agent = new HttpsAgent({ keepAlive: true, timeout: timeoutConfig.timeout, keepAliveTimeout: timeoutConfig.keepAliveTimeout, + checkServerIdentity, rejectUnauthorized: verifySsl }) @@ -40,6 +46,7 @@ function createHttpsAgent (timeoutConfig, verifySsl) { keepAlive: true, timeout: timeoutConfig.timeout, keepAliveTimeout: timeoutConfig.keepAliveTimeout, + checkServerIdentity, rejectUnauthorized: false })