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

本文由清尘发表于2020-05-25 14:36最后修改于2020-05-26属于Node.js分类

报错代码:

{ Error: certificate has expired
    at TLSSocket.onConnectSecure (_tls_wrap.js:1055:34)
    at TLSSocket.emit (events.js:182:13)
    at TLSSocket._finishInit (_tls_wrap.js:635:8) code: 'CERT_HAS_EXPIRED' }

解决方法:

在构造http请求时,指定:

strictSSL: false, // allow us to use our self-signed cert for testing
rejectUnauthorized: false