我正在尝试使用Auth0的库idtoken-verifier验证客户端的JWT,并在检查我的公钥(https://github.com/auth0/idtoken-verifier/blob/master/src/helpers/rsa-verifier.js#L25)的模数和指数时抛出错误
公钥:<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="formid">
</form>
我找不到有关如何从ssh-keygen生成的密钥中获取模数和exp的任何信息,因此我尝试在本文(How to store/retrieve RSA public/private key)的帮助下手动将其提取以获取:>
exp :AQAB-> 65537
模量:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmg9TCgeL+aTFrr6MiZ/FXcuh846XlQLHgDMIHDX74x1zwPPlx+voqx7sO4YH4wzmUjoA6XURj9tZSwFnWBkSntcvEMQLoN3ydKpSv0m8K8CQnOimZoRH5zEdGnkG2rIswcobuaqXUYHqLmQV1+vxY+ScX46/0+dVmLdhY9SjdgkTsO3N3GGlGXZIL92nmBVzD1gRKbMT9Lx0ZqHwTUGTxUcA4OxNojIRYX6B0xbyCBOlOn2p4lhOXJE8UypvHz6vhmP9FkCqrAVW/ii0S2hQnhR8aYQALsyQOig+ItR92VzGi/KyULx3fiNdeYe/rlxRffpNTWrun9xuM6aZwBLRp
这是库中的函数
AQDmg9TCgeL+aTFrr6MiZ/FXcuh846XlQLHgDMIHDX74x1zwPPlx+voqx7sO4YH4wzmUjoA6XURj9tZSwFnWBkSntcvEMQLoN3ydKpSv0m8K8CQnOimZoRH5zEdGnkG2rIswcobuaqXUYHqLmQV1+vxY+ScX46/0+dVmLdhY9SjdgkTsO3N3GGlGXZIL92nmBVzD1gRKbMT9Lx0ZqHwTUGTxUcA4OxNojIRYX6B0xbyCBOlOn2p4lhOXJE8UypvHz6vhmP9FkCqrAVW/ii0S2hQnhR8aYQALsyQOig+ItR92VzGi/KyULx3fiNdeYe/rlxRffpNTWrun9xuM6aZwBLRp
验证者
function RSAVerifier(modulus, exp) {
this.n = null;
this.e = 0;
if (modulus != null && exp != null && modulus.length > 0 && exp.length > 0) {
this.n = new BigInteger(modulus, 16);
this.e = parseInt(exp, 16);
} else {
throw new Error('Invalid key data');
}
}
DummyCache()
const verifier = new IdTokenVerifier({
issuer: 'https://somevalidurl.com',
audience: 'access',
expectedAlg: 'RS256',
jwksCache: new DummyCache(),
});
我想我对模数参数的期望感到困惑,我试图将上述模数转换为几种不同的形式(十六进制,通过https://lapo.it/asn1js/等),但是没有运气。