添加SSL证书回调函数并记录日志。
parent
616152db69
commit
b5764c8ee9
|
@ -29,10 +29,16 @@ function createHttpsAgent (timeoutConfig, verifySsl) {
|
||||||
if (!httpsAgentCache[key]) {
|
if (!httpsAgentCache[key]) {
|
||||||
verifySsl = !!verifySsl
|
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({
|
const agent = new HttpsAgent({
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
timeout: timeoutConfig.timeout,
|
timeout: timeoutConfig.timeout,
|
||||||
keepAliveTimeout: timeoutConfig.keepAliveTimeout,
|
keepAliveTimeout: timeoutConfig.keepAliveTimeout,
|
||||||
|
checkServerIdentity,
|
||||||
rejectUnauthorized: verifySsl
|
rejectUnauthorized: verifySsl
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -40,6 +46,7 @@ function createHttpsAgent (timeoutConfig, verifySsl) {
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
timeout: timeoutConfig.timeout,
|
timeout: timeoutConfig.timeout,
|
||||||
keepAliveTimeout: timeoutConfig.keepAliveTimeout,
|
keepAliveTimeout: timeoutConfig.keepAliveTimeout,
|
||||||
|
checkServerIdentity,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue