RTCCertificate: expires 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流浏览器均已支持。

RTCCertificate 接口的只读 expires 属性返回证书的过期日期。

默认情况下,新证书的 expires 设置为 2592000000 毫秒(即 30 天)。过期时间不能超过 31536000000 毫秒(即 365 天)。还需要注意的是,浏览器可能会根据其选择进一步限制证书的过期时间。

一个时间戳,以毫秒为单位的 Unix 时间,包含证书的过期日期。

示例

js
RTCPeerConnection.generateCertificate({
  name: "RSASSA-PKCS1-v1_5",
  hash: "SHA-256",
  modulusLength: 2048,
  publicExponent: new Uint8Array([1, 0, 1]),
}).then((cert) => {
  const pc = new RTCPeerConnection({ certificates: [cert] });
  console.log(cert.expires); // 2592000000 (30 days, the default)
});

规范

规范
WebRTC:浏览器中的实时通信
# dom-rtccertificate-expires

浏览器兼容性

另见