Harry Pehkonen
Harry Pehkonen

Reputation: 3038

In-House Certificate Authority (CA) for Node.js https.request: How to point to .PEM?

I recently updated from Node 0.8.xx to 0.10.5. Suddenly, my https.request calls started failing. I believe 0.8.x was not verifying certificates, but 0.10.5 is. We have some in-house certificate authorities set up to verify internal https traffic. I would like to show Node.js https.request client the certificates. How do I do this?

Currently, I'm getting:

Problem with request:  UNABLE_TO_VERIFY_LEAF_SIGNATURE

I have tried:

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) {
    ....

The calls work if I set rejectUnauthorized: false, but I'd like to start taking advantage of the improved security in Node 0.10.5.

I believe my .pem file is good because it works with Python httplib2 (${python}/Lib/site-packages/httplib2/cacerts.txt) and cURL ("curl-ca-bundle.crt").

Upvotes: 2

Views: 1693

Answers (1)

jmingov
jmingov

Reputation: 14003

well, maybe these helps,

/whatever/path/ must be a relative folder of your proyect.

Upvotes: 0

Related Questions