Web Crypto API:importKey在Firefox中不起作用 [英] Web Crypto API: importKey does not work in Firefox

查看:591
本文介绍了Web Crypto API:importKey在Firefox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google Chrome 46和Firefox 41( JSBin ):

  window.crypto.subtle.importKey(
jwk,//可以是jwk (公有或私有),spki(仅公共)或pkcs8(仅限私人)
{//这是一个jwk键的示例,其他键类型是Uint8Array对象
kty:RSA ,$ b $是: AQAB,
N: vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE,
ALG: PS256,
分机:真实,
},
{//这些是算法选项
名称:RSA-PSS,
hash:{name:SHA-256},//可以是SHA-1, SHA-256,SHA-384或SHA-512
},
false,//是否可以提取密钥(即可以在exportKey中使用)
[ 验证] //验证pu blic键导入,签为私钥导入

.then(
结果=> console.log('Ok',result),
e => console.error(e.message)

在Firefox中指定错误或非法的字符串错误。哪个字符串是无效的或非法的,为什么?

/ code>算法。您可以通过错误1191936 跟踪该错误以在WebCrypto中实施。


I tried this example for importKey in Google Chrome 46 and Firefox 41 (JSBin):

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

It works in Chrome, but I get An invalid or illegal string was specified error in Firefox. Which string is invalid or illegal and why?

解决方案

Firefox does not yet support the RSA-PSS algorithm. You can track the bug to implement it for WebCrypto at Bug 1191936.

这篇关于Web Crypto API:importKey在Firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆