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

pull/375/head
王良 2024-09-29 23:58:27 +08:00
parent 616152db69
commit b5764c8ee9
1 changed files with 7 additions and 0 deletions

View File

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