添加SSL证书回调函数并记录日志。

pull/375/head
王良 2 months ago
parent 616152db69
commit b5764c8ee9

@ -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
})

Loading…
Cancel
Save