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.
- : A string containing the certificate fingerprint, which is calculated using the hash function specified in
- RTCCertificateStats.fingerprintAlgorithm
- : A string containing the hash function used to compute the certificate
fingerprint, such as "sha-256".
- : A string containing the hash function used to compute the certificate
- RTCCertificateStats.issuerCertificateId
- : A string containing the
idof theRTCCertificateStatsobject 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).
- : A string containing the
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.
- : A string with the value
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。离线整理了版式、链接和媒体显示。
