我需要生成一个公钥来验证来自Cognito的JWT令牌。这是钥匙:
{
keys: [
{
alg: "RS256",
e: "AQAB",
kid: "7sbG73+G/8A+wPT4Vaf/+ttnBHuLZcjEmfiBXl3E8Fk=",
kty: "RSA",
n: "blablablablabla",
use: "sig"
},
{
alg: "RS256",
e: "AQAB",
kid: "Zbf1euSHNj4lXgXHIQwYZfERTdm1Rkeqrm1ppnpClRR=",
kty: "RSA",
n: "blablablablabla",
use: "sig"
}
]
}
我可以很容易地用来自Azure的X5C密钥创建它,但是我不能用Cognito来创建它。我应该使用哪个键来创建rsapublickey?
CertificateFactory factory = CertificateFactory.getInstance("X.509");
//Creating a cert from x5c key
X509Certificate cert = (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(DatatypeConverter.parseBase64Binary(x5c)));
RSAPublicKey publicKey = (RSAPublicKey) cert.getPublicKey();
RSAPrivateKey privateKey = null;