【问题标题】:RTCPeerConnection.generateCertificate() is returning an empty objectRTCPeerConnection.generateCertificate() 返回一个空对象
【发布时间】:2020-06-22 17:16:08
【问题描述】:

这是代码(Ubuntu 上的浏览​​器 Chrome):

   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);
               } 
             );

它显示:

   typeof: object
   S: {}

其实这和Mozilla site的代码差不多

同时,符合 WebRTC specs Section 4.9

【问题讨论】:

    标签: webrtc mozilla client-certificates rtcpeerconnection


    【解决方案1】:

    证书不可序列化。如果您添加console.log(cert);,您会看到类似于RTCCertificate { expires: 1595444355114 } 的内容。这是故意的,您不能像在 webcrypto 中那样导出密钥。而且没有toJSON

    【讨论】:

    • 是否有获取证书指纹的API?这无论如何都可以在 sdp 中作为 a=fingerprint 获得?
    【解决方案2】:

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

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

    是一个练习 generateCertificate() 的页面

    【讨论】:

      猜你喜欢
      • 2021-03-31
      • 2014-07-15
      • 2018-08-25
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-24
      相关资源
      最近更新 更多