The hostname to connect to.
Optional parameters to configure the connection.
import { getCertificate } from 'sslko';
const cert = await getCertificate('example.com');
console.log(cert);
import { getCertificate } from 'sslko';
const cert = await getCertificate('example.com', { rejectUnauthorized: true });
console.log(cert);
import { getCertificate } from 'sslko';
const cert = await getCertificate('example.com', { port: 8443 });
console.log(cert);
Fetches the SSL/TLS certificate from a given host and port.
Note: When
detailedis true (the default), the returnedDetailedPeerCertificatecontains a circularissuerCertificatereference (the root CA cert points to itself). This will causeJSON.stringifyto throw. Use getCertificateInfo for a serialization-safe result, or remove the circular reference before serializing.Note:
rejectUnauthorizeddefaults tofalse— the TLS handshake will succeed even for expired or self-signed certificates. Use getCertificateInfo for validation, or passrejectUnauthorized: trueto let Node.js verify the certificate.This function does not check certificate revocation (OCSP/CRL).