欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

node.js請(qǐng)求HTTPS報(bào)錯(cuò):UNABLE_TO_VERIFY_LEAF_SIGNATURE\的解決方法

 更新時(shí)間:2016年12月18日 15:46:56   投稿:daisy  
最近在工作中遇到一個(gè)問題,node.js請(qǐng)求HTTPS時(shí)報(bào)錯(cuò):Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE\,通過查找網(wǎng)上的一些資料找到了解決方法,現(xiàn)在總結(jié)下分享給大家,有需要的朋友們可以參考借鑒,下面來一起看看吧。

發(fā)現(xiàn)錯(cuò)誤

最近在用Nodejs發(fā)送https請(qǐng)求時(shí)候,出現(xiàn)\”Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE\”的錯(cuò)誤,錯(cuò)誤如下:

events.js:72
throw er; // Unhandled \'error\' event
^
Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
at SecurePair. (tls.js:1381:32)
at SecurePair.emit (events.js:92:17)
at SecurePair.maybeInitFinished (tls.js:980:10)
at CleartextStream.read [as _read] (tls.js:472:13)
at CleartextStream.Readable.read (_stream_readable.js:341:10)
at EncryptedStream.write [as _write] (tls.js:369:25)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at EncryptedStream.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:602:24)

錯(cuò)誤的原因是:對(duì)方數(shù)字證書設(shè)置不正確,

解決辦法: 將rejectUnauthorized參數(shù)設(shè)置成false

var https = require(\'https\'); 
 
var options = { 
 hostname: \'www.magentonotes.com\', 
 port: 443, 
 path: \'/\', 
 method: \'GET\', 
 rejectUnauthorized:false 
}; 
 
var req = https.request(options, function(res) { 
 console.log(\"statusCode: \", res.statusCode); 
 console.log(\"headers: \", res.headers); 
 
 res.on(\'data\', function(d) { 
 process.stdout.write(d); 
 }); 
}); 
req.end(); 
 
req.on(\'error\', function(e) { 
 console.error(e); 
});

參考資料:https://nodejs.org/api/https.html

總結(jié)

以上就是關(guān)于node.js請(qǐng)求HTTPS報(bào)錯(cuò)的解決方法,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。

相關(guān)文章

最新評(píng)論