Ignore invalid self-signed ssl certificate in node.js with https.request? -
i'm working on little app logs local wireless router (linksys) i'm running problem router's self-signed ssl certificate.
i ran wget 192.168.1.1 , get:
error: cannot verify 192.168.1.1's certificate, issued `/c=us/st=california/l=irvine/o=cisco-linksys, llc/ou=division/cn=linksys/emailaddress=support@linksys.com': self-signed certificate encountered. error: certificate common name `linksys' doesn't match requested host name `192.168.1.1'. connect 192.168.1.1 insecurely, use `--no-check-certificate'. in node, error being caught is:
{ [error: socket hang up] code: 'econnreset' } my current sample code is:
var req = https.request({ host: '192.168.1.1', port: 443, path: '/', method: 'get' }, function(res){ var body = []; res.on('data', function(data){ body.push(data); }); res.on('end', function(){ console.log( body.join('') ); }); }); req.end(); req.on('error', function(err){ console.log(err); }); how can go getting node.js equivalent of "--no-check-certificate"?
cheap , insecure answer:
add
process.env.node_tls_reject_unauthorized = "0"; in code, before calling https.request()
a more secure way (the solution above makes whole node process insecure) answered in question
Comments
Post a Comment