Disabling SSL certificate checking in unirest (NodeJS)


You want to make a HTTP request with unirest like this:

const unirest = require('unirest');

but you encounter the following error:

{ error: 
   { Error: unable to verify the first certificate
       at TLSSocket.<anonymous> (_tls_wrap.js:1088:38)
       at emitNone (events.js:86:13)
       at TLSSocket.emit (events.js:188:7)
       at TLSSocket._finishInit (_tls_wrap.js:610:8)
       at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' } }


You can work around this problem by using strictSSL(false) like this:

const unirest = require('unirest');


Note however that this might have negative effects on the security of your application as this request will be vulnerable to man-in-the-middle attacks.