x509-certificate
v1.1.1
Published
Retrieve the public TLS certificate in x509 format from a distant host
Downloads
133
Readme
node-x509-certificate
Retrieve the public TLS certificate in x509 format from a distant host
npm
npm install x509-certificate --save
usage
getCertificate(port, host, callback)
getCertificate(443, 'redsmin.com', (err, certificate) => {
if(err){
throw err;
}
console.log(certificate); // x509 certificate
});
host
: host the client should connect toport
: port the client should connect tocallback(err: {Error,Null}, certificate: String)
getCertificate(port, host, options, callback)
getCertificate(443, 'my-very-own-sni-host.com', {
rejectUnauthorized: true,
servername: 'my-very-own-sni-host.com'
}, (err, certificate) => {
if(err){
throw err;
}
console.log(certificate); // x509 certificate
});
option
object is the same astls.connect
option object
cli
> npm i x509-certificate -g
> x509-certificate redsmin.com:443
-----BEGIN CERTIFICATE-----
MIIGTzCCBTegAwIBAgIRAKxlFKZ9eTAZfc5c8P1qvq4wDQYJKoZIhvcNAQELBQAw
gZAxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO
BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMTYwNAYD
VQQDEy1DT01PRE8gUlNBIERvbWFpbiBWYWxpZGF0aW9uIFNlY3VyZSBTZXJ2ZXIg
Q0EwHhcNMTUwNTE4MDAwMDAwWhcNMTYwOTA1MjM1OTU5WjBaMSEwHwYDVQQLExhE
b21haW4gQ29udHJvbCBWYWxpZGF0ZWQxHTAbBgNVBAsTFFBvc2l0aXZlU1NMIFdp
bGRjYXJkMRYwFAYDVQQDFA0qLnJlZHNtaW4uY29tMIICIjANBgkqhkiG9w0BAQEF
AAOCAg8AMIICCgKCAgEA1hCv9a75urP4TQpMAyyqatxraT5dnkbNfgnio/oekqNN
wNLfWzJDFVCatPrlXLFsTYjP5fAesnibGKP9rT6c6Tx5izFbloiV72R8Cay3pQjo
l0sVZBaYJhd9MWvlQN/EaLggiRvf4ksucEhuvvCWRXVuWj0D3YWTvicUUcrMCA/0
w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