場景:
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