sslko - v2.0.2
    Preparing search index...

    Function getCertificate

    • Fetches the SSL/TLS certificate from a given host and port.

      Parameters

      • host: string

        The hostname to connect to.

      • options: Partial<GetCertificateOptions> = {}

        Optional parameters to configure the connection.

      Returns Promise<DetailedPeerCertificate | PeerCertificate>

      If the connection times out or if there is an error retrieving the certificate.

      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);
      import { getCertificate } from 'sslko';
      const cert = await getCertificate('example.com', { detailed: false });
      console.log(cert);

      When enabled, TLS packet trace information is written to stderr. This can be used to debug TLS connection problems.

      import { getCertificate } from 'sslko';
      const cert = await getCertificate('example.com', { enableTrace: true });