2013-05-07 132 views
2

我最近從節點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」)一起使用。

回答

1

好,也許這些幫助,

/whatever/path/必須是你proyect的相對文件夾。