0

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

asinix
  • 966
  • 1
  • 9
  • 22

2 Answers2

1

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

Philipp Hancke
  • 15,855
  • 2
  • 23
  • 31
  • Is there an API to get fingerprint of the certificate? This is anyway available in the sdp as a=fingerprint? – asinix Jun 22 '20 at 20:00
1

Yes, cert.getFingerprints()[0].value.toUpperCase().trim();

https://pi.pe/p/genCertTest.html

is a page that exercises generateCertificate()

Tim Panton
  • 469
  • 3
  • 4