Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request, Error: unable to verify the first certificate

I wanted to make simple POST HTTP request by using request module:

var request = require("request");
var form = {form: {some: "form", attributes: "attrs"}}
request.post("https://example.com", form)
   .on('response', function(response) {

   if (response.statusCode === 200) {
     console.log("DONE");
   } else {
     console.log("FAIL");
   }
});

When I launch this code it throws me this error message:

Error: unable to verify the first certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1057:38)
at emitNone (events.js:67:13)
at TLSSocket.emit (events.js:166:7)
at TLSSocket._finishInit (_tls_wrap.js:596:8)

I think this is happening because url has https, but I don't know how to fix this error.

How to disable checking certificate?

like image 922
Mr.D Avatar asked Mar 24 '16 06:03

Mr.D


People also ask

How do I fix unable to verify the first certificate in Postman?

Just turning SSL off worked for me. Save this answer.

Could not obtain grant code error unable to verify the first certificate?

It means that the webserver you are connecting to is misconfigured and did not include the intermediate certificate in the certificate chain it sent to you.


2 Answers

Add "rejectUnauthorized": false as option:

request.post({url: "https://example.com", "rejectUnauthorized": false}, form)
   .on('response', function(response) {

   if (response.statusCode === 200) {
     console.log("DONE");
   } else {
     console.log("FAIL");
   }
});

Or add the appropiate certificate via https://www.npmjs.com/package/ssl-root-cas

require('ssl-root-cas').inject();
like image 92
michelem Avatar answered Sep 30 '22 00:09

michelem


You can try with disabling ssl certificate verification under File->Settings Settings image

like image 27
FJJ Avatar answered Sep 29 '22 23:09

FJJ