Here is the code (browser Chrome on Ubuntu):
RTCPeerConnection.generateCertificate(
{ name: "RSASSA-PKCS1-v1_5",
modulusLength: 2048,
publicExponent: new Uint8Array([1, 0, 1]),
hash: "SHA-256" })
.then
( function(cert) {
console.log("typeof: " + typeof(cert));
console.log("S: " + JSON.stringify(cert));
},
function(err) {
console.log("E: " + err);
}
);
It displays:
typeof: object
S: {}
Actually this is almost the exact code from Mozilla site
Also, conforms to the WebRTC specs Section 4.9
The certificate isn't serializable. If you add a console.log(cert);
you'll see something along the lines of RTCCertificate { expires: 1595444355114 }
. That is intentional, you can not export the key like you can in webcrypto. And there is no toJSON