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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM