securityDetails()
返回 SSL 和其他安全信息。
返回值
类型 | 描述 |
---|---|
Promise<SecurityDetails | null> | 返回 SecurityDetails。 |
SecurityDetails
属性 | 类型 | 描述 |
---|---|---|
subjectName | string | Subject 字段的 Common Name 组件。此值从证书中提取。这仅应作为参考信息使用。 |
issuer | string | Issuer 字段的 Common Name 组件。此值从证书中提取。这仅应作为参考信息使用。 |
validFrom | number | Unix 时间戳(秒),指定此证书生效的确切日期/时间。 |
validTo | number | Unix 时间戳(秒),指定此证书失效的确切日期/时间。 |
protocol | string | 使用的具体 TLS 协议。例如 TLS 1.3 。 |
sanList | string[] | 证书的十六进制编码 SHA256 指纹字符串。此值从证书中提取。 |
示例
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();
}
}