Skip to content

Instantly share code, notes, and snippets.

@oscarkuo
Last active April 22, 2016 01:41
Show Gist options
  • Save oscarkuo/a6bd00b39192fbe46366bdcef63008fa to your computer and use it in GitHub Desktop.
Save oscarkuo/a6bd00b39192fbe46366bdcef63008fa to your computer and use it in GitHub Desktop.
Bypass bad SSL check in Node request
// npm i request-promise
// node node-bad-ssl-test.js
const rp = require('request-promise');
const url = 'https://self-signed.badssl.com';
const r1 = rp.get(url, { rejectUnauthorized: true });
r1.then((body) => {
console.log(`with rejectUnauthorized => {${body}}`);
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
rp.get(url).then(body => console.log(`with NODE_TLS_REJECT_UNAUTHORIZED => {${body}}`));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment