这段证书名称检查会输出什么?

来自 TLS 连接
Node 24 进阶 4分钟

这段证书名称检查会输出什么?

JavaScript
import { checkServerIdentity } from "node:tls";

const cert = {
  subjectaltname: "DNS:api.internal, DNS:*.svc.internal",
};

for (const host of ["api.internal", "orders.svc.internal", "bad.internal"]) {
  const error = checkServerIdentity(host, cert);
  console.log(`${host}: ${error?.code ?? "ok"}`);
}
在试验场中打开
报告错误