我最近从 Node 0.8.xx 更新到 0.10.5。突然,我的 https.request 调用开始失败。我相信 0.8.x 没有验证证书,但 0.10.5 是。我们设置了一些内部证书颁发机构来验证内部 https 流量。我想向 Node.js https.request 客户端显示证书。我该怎么做呢?
目前,我得到:
Problem with request: UNABLE_TO_VERIFY_LEAF_SIGNATURE
我努力了:
var https_request_options = {
host: 'myhost.com',
path: '/thepath',
port: 443,
method: 'POST',
headers: {
'Content-type': "application/x-www-form-urlencoded",
'Content-length': thebody.length,
},
// rejectUnauthorized: false,
ca: [fs.readFileSync('/whatever/path/ca_certs.pem')]
};
var authRequest = https.request(https_request_options, function(response) {
....
如果我设置rejectUnauthorized: false
,调用就可以工作,但我想开始利用 Node 0.10.5 中改进的安全性。
我相信我的 .pem 文件很好,因为它适用于 Python httplib2 (${python}/Lib/site-packages/httplib2/cacerts.txt) 和 cURL ("curl-ca-bundle.crt")。