node.js request请求url错误:证书已过期 Error: certificate has expired

场景:

node:8.9.3版本

报错代码:

Error: certificate has expired
    at TLSSocket.<anonymous> (_tls_wrap.js:1103:38)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket._finishInit (_tls_wrap.js:637:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:467:38)

解决方法:

1、由于CA证书过期导致的,原因是证书由Comodo签发,Sectigo目前提供了与AddTrust旧版根交叉签署证书的功能,以增加非常旧的系统和设备之间的支持。*此根将于2020年5月底过期。更新ca证书即可。(找证书提供商或者https://whatsmychaincert.com/)

2、在构造http请求时,指定:

strictSSL: false, // allow us to use our self-signed cert for testing
rejectUnauthorized: false
原文地址:https://www.cnblogs.com/cptao/p/12995770.html