Skip to content

Commit

Permalink
添加SSL证书回调函数并记录日志。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Sep 29, 2024
1 parent 616152d commit b5764c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/mitmproxy/src/lib/proxy/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,24 @@ 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
})

agent.unVerifySslAgent = new HttpsAgent({
keepAlive: true,
timeout: timeoutConfig.timeout,
keepAliveTimeout: timeoutConfig.keepAliveTimeout,
checkServerIdentity,
rejectUnauthorized: false
})

Expand Down

0 comments on commit b5764c8

Please sign in to comment.