Webcrypto:Promise返回权限在Edge上被拒绝

时间:2018-10-09 04:09:58

标签: javascript promise microsoft-edge digital-signature webcryptoapi

我已经在Chrome和Firefox上成功使用了Web Crypto API。但是当我使用Microsoft Edge测试代码时失败了。权限被拒绝在对象Promise中返回。尽管我运行了简单的crypto.subtle.generateKey,但仍然失败。请参考下面的代码。

return window.crypto.subtle.importKey(
        "jwk", //can be "jwk" (public or private), "spki" (public only), or "pkcs8" (private only)
        {   
            kty: "EC",
            crv: "P-256",
            x: xb64,
            y: yb64,
            d: db64
        },
        {   //these are the algorithm options
            name: "ECDSA",
            namedCurve: "P-256", //can be "P-256", "P-384", or "P-521"
        },
        false, //whether the key is extractable (i.e. can be used in exportKey)
        ["sign"] //"verify" for public key import, "sign" for private key imports
    )
    .then(function(key){           
        return key;
    })

1 个答案:

答案 0 :(得分:1)

我尝试检查crypto API的文档。

我在下面找到链接的地方。

实时显示对特定浏览器方法的支持。

Web Cryptography API Live Table

以下是Edge中ECDSA P-256方法的输出。

enter image description here

似乎Edge不支持它。

如果您在Chrome中打开同一页面,则会看到它受支持。