Menu
Open source

securityDetails()

Returns SSL and other security information.

Returns

TypeDescription
Promise<SecurityDetails | null>Returns SecurityDetails.

SecurityDetails

PropertyTypeDescription
subjectNamestringCommon Name component of the Subject field. The value is extracted from the certificate. This should only be used for informational purposes.
issuerstringCommon Name component of the Issuer field. The value is extracted from the certificate. This should only be used for informational purposes.
validFromnumberUnix timestamp (in seconds) specifying the exact date/time when this cert becomes valid.
validTonumberUnix timestamp (in seconds) specifying the exact date/time when this cert becomes invalid.
protocolstringThe specific TLS protocol used. For example TLS 1.3.
sanListstring[]String with hex encoded SHA256 fingerprint of the certificate. The value is extracted from the certificate.

Example

JavaScript
import { browser } from 'k6/browser';

export const options = {
  scenarios: {
    ui: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const page = await browser.newPage();

  try {
    const res = await page.goto('https://test.k6.io/');

    const sd = await res.securityDetails();
    console.log(`securityDetails: ${JSON.stringify(sd)}`); // securityDetails: {"subject_name":"*.k6.io"...}
  } finally {
    await page.close();
  }
}