Web Crypto API:importKey 在 Firefox 中不起作用

Web Crypto API: importKey does not work in Firefox

我在 Google Chrome 46 和 Firefox 41 (JSBin) 中尝试了这个 importKey 示例:

window.crypto.subtle.importKey(
    "jwk", //can be "jwk" (public or private), "spki" (public only), or "pkcs8" (private only)
    {   //this is an example jwk key, other key types are Uint8Array objects
        kty: "RSA",
        e: "AQAB",
        n: "vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE",
        alg: "PS256",
        ext: true,
    },
    {   //these are the algorithm options
        name: "RSA-PSS",
        hash: {name: "SHA-256"}, //can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
    },
    false, //whether the key is extractable (i.e. can be used in exportKey)
    ["verify"] //"verify" for public key import, "sign" for private key imports
)
.then(
  result => console.log('Ok', result),
  e => console.error(e.message)
)

它在 Chrome 中有效,但我在 Firefox 中收到 指定了无效或非法字符串 错误。哪个字符串无效或非法,为什么?

Firefox 尚不支持 RSA-PSS 算法。您可以跟踪错误以在 Bug 1191936.

为 WebCrypto 实施它