Geuis Geuis - 2 months ago 20x
Node.js Question

Ignore invalid self-signed ssl certificate in node.js with https.request?

I'm working on a little app that logs into my local wireless router (Linksys) but I'm running into a problem with the router's self-signed ssl certificate.

I ran wget and get:

ERROR: cannot verify's certificate, issued by `/C=US/ST=California/L=Irvine/O=Cisco-Linksys, LLC/OU=Division/CN=Linksys/':
Self-signed certificate encountered.
ERROR: certificate common name `Linksys' doesn't match requested host name `'.
To connect to insecurely, use `--no-check-certificate'.

In node, the error being caught is:

{ [Error: socket hang up] code: 'ECONNRESET' }

My current sample code is:

var req = https.request({
host: '',
port: 443,
path: '/',
method: 'GET'

}, function(res){

var body = [];
res.on('data', function(data){

res.on('end', function(){
console.log( body.join('') );


req.on('error', function(err){

How can I go about getting node.js to do the equivalent of "--no-check-certificate"?


Cheap and insecure answer:



in code, before calling https.request()

A more secure way (the solution above makes the whole node process insecure) is answered in this question