Skip to content

Commit

Permalink
Merge pull request #22 from DanielRuf/feature/detailed-certificate-ch…
Browse files Browse the repository at this point in the history
…ains

feature: add detailed parameter to output the certificate chain
  • Loading branch information
johncrisostomo committed Oct 18, 2019
2 parents c915b14 + f3be86e commit ee1a1fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Expand Up @@ -42,9 +42,9 @@ function validateUrl(url) {
}
}

function handleRequest(options, resolve, reject) {
function handleRequest(options, detailed = false, resolve, reject) {
return https.get(options, function(res) {
var certificate = res.socket.getPeerCertificate();
var certificate = res.socket.getPeerCertificate(detailed);

if (isEmpty(certificate) || certificate === null) {
reject({ message: 'The website did not provide a certificate' });
Expand All @@ -57,7 +57,7 @@ function handleRequest(options, resolve, reject) {
});
}

function get(url, timeout, port, protocol) {
function get(url, timeout, port, protocol, detailed) {
validateUrl(url);

port = port || 443;
Expand All @@ -66,7 +66,7 @@ function get(url, timeout, port, protocol) {
var options = getOptions(url, port, protocol);

return new Promise(function(resolve, reject) {
var req = handleRequest(options, resolve, reject);
var req = handleRequest(options, detailed, resolve, reject);

if (timeout) {
req.setTimeout(timeout, function() {
Expand Down

0 comments on commit ee1a1fd

Please sign in to comment.