Skip to content

Instantly share code, notes, and snippets.

@rjnienaber
Created July 27, 2016 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjnienaber/87a1427e5084c5bb277084de70e8d2ac to your computer and use it in GitHub Desktop.
Save rjnienaber/87a1427e5084c5bb277084de70e8d2ac to your computer and use it in GitHub Desktop.
var request = require('request');
var fs = require('fs');
var url = process.argv[2]; // url of the site
var certFile = process.argv[3]; // certificate from server
var ca = fs.readFileSync(certFile, 'ascii');
var options = {
url: url,
// rejectUnauthorized: false,
ca: ca
};
var test = request.get(options, function (error, response, body) {
if (error) {
console.log('Error');
console.log(JSON.stringify(error, null, 4));
} else {
delete response['body'];
console.log(JSON.stringify(response, null, 4)) // Show the HTML for the Google homepage.
}
});
// NODE 4.4.7 (Ubuntu 16.04 LTS)
// Error
// {
// "code": "UNABLE_TO_GET_ISSUER_CERT"
// }
// NODE 6.0.0 (Ubuntu 16.04 LTS)
// {
// "statusCode": 200,
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment