Using node.js request with lets encrypt "unable to verify the first certificate" error

1.5k views Asked by At

I am using node-slack to use the Mattermost incoming URL Api for a self hosted mattermost. This mattermost is secured by lets-encrypt.

My node code is working with the slack api, and i have testet the send data with Postman (manual post tool) against the MM server.

In both cases it is working.

But with node i receive a unable to verify the first certificate error.

In "https://nodejs.org/api/https.html" I can see, that node.js is supporting a "well known" set of root CAs.

To simplify the question, I have written this small peace of code:

let request = require('request');

request("https:--letsencryptsecuredsite",function(err,body){
  console.log(err);
  console.log(body);
});

This results in

{ Error: unable to verify the first certificate
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1079:38)
    at emitNone (events.js:86:13)
    at TLSSocket.emit (events.js:185:7)
    at TLSSocket._finishInit (_tls_wrap.js:603:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:433:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }

What do i have to use an API on a lets encrypt secured server ?

I am using node version 6.9.2.

0

There are 0 answers