Node.js的内部证书颁发机构(CA)https.request:如何指向.PEM?

问题描述:

我最近从节点0.8.xx更新为0.10.5。突然,我的https.request调用开始失败。我相信0.8.x没有验证证书,但0.10.5是。我们设置了一些内部认证中心来验证内部https流量。我想向Node.js https.request客户端显示证书。我该怎么做呢?Node.js的内部证书颁发机构(CA)https.request:如何指向.PEM?

目前,我得到:

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,但我想开始服用改进的安全优势在节点0.10.5中。

我相信我的.pem文件很好,因为它可以与Python httplib2($ {python} /Lib/site-packages/httplib2/cacerts.txt)和cURL(“curl-ca-bundle.crt”)一起使用。

好,也许这些帮助,

/whatever/path/必须是你proyect的相对文件夹。