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
.
The following properties are common to all WebRTC statistics objects (See RTCStatsReport
for more information).
id
-
A string that uniquely identifies the object that is being monitored to produce this set of statistics.
timestamp
-
A DOMHighResTimeStamp
object indicating the time at which the sample was taken for this statistics object.
type
-
A string with the value "certificate"
, indicating the type of statistics that the object contains.
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") {
console.log(report);
}
});