大网数据广告活动
Web 标准与前端开发

RTCCertificateStats

· 52CE 我爱测

The **`RTCCertificateStats`** dictionary of the WebRTC API is used to report information about a certificate used by an RTCDtlsTransport and its underlying RTCIceTransport.

WebRTC

The RTCCertificateStats dictionary of the WebRTC API is used to report information about a certificate used by an RTCDtlsTransport and its underlying RTCIceTransport.

The report can be obtained by iterating the RTCStatsReport returned by RTCPeerConnection.getStats() until you find an entry with the type of certificate.

Instance properties

  • RTCCertificateStats.base64Certificate
    • : A string containing the base-64 representation of the DER-encoded certificate.
  • RTCCertificateStats.fingerprint
    • : A string containing the certificate fingerprint, which is calculated using the hash function specified in fingerprintAlgorithm.
  • RTCCertificateStats.fingerprintAlgorithm
    • : A string containing the hash function used to compute the certificate fingerprint, such as "sha-256".
  • RTCCertificateStats.issuerCertificateId
    • : A string containing the id of the RTCCertificateStats object in this report that contains the next certificate in the certificate chain. This will not be set if the current certificate is a self-signed certificate or the end of the certificate chain (a root certificate).

Common instance properties

The following properties are common to all WebRTC statistics objects (See RTCStatsReport for more information).

  • RTCCertificateStats.id
    • : A string that uniquely identifies the object that is being monitored to produce this set of statistics.
  • RTCCertificateStats.timestamp
    • : A DOMHighResTimeStamp object indicating the time at which the sample was taken for this statistics object.
  • RTCCertificateStats.type
    • : A string with the value "certificate", indicating the type of statistics that the object contains.

Examples

Basic usage

Given a variable myPeerConnection, which is an instance of RTCPeerConnection, the code below uses await to wait for the statistics report, and then iterates it using RTCStatsReport.forEach(). It then filters the dictionaries for just those reports that have the type of certificate and logs the result.

const stats = await myPeerConnection.getStats();

stats.forEach((report) => {
  if (report.type === "certificate") {
    // Log the certificate information
    console.log(report);
  }
});

Specifications

Browser compatibility

See also

  • RTCStatsReport
  • RTCCertificate

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。