How to gen a jwk with kid?
mfdefs opened this issue · 3 comments
like this:
{
"e": "AQAB",
"kid": "uncK0PWuznliRSr2pB4vtgcdLKYBnTngUV70GPc0Yxc",
"kty": "RSA",
"n": "..."
}
It can been gen by under python code
need install jwcrypto: pip install jwcrypto
from jwcrypto.jwk import JWK
from pathlib import Path
private_key = Path("./rsa-private-key.pem").read_bytes()
jwk = JWK.from_pem(private_key)
jwk_bytes = jwk.public().export()
print(jwk_bytes)
Can you provide some additional context or detail as to what you'd like this library to do?
The JSONWebKeyBuilder
will return a JSONWebKey
. Once you have a reference to that object, you can set the kid
to whatever you like.
String pem = "a pem";
JSONWebKey jwk = JSONWebKey.build(pem);
jwk.kid = "foo";
I am lack of basic conception about jwk. Only I can say is gen a jwk with kid like under code:
https://github.com/latchset/jwcrypto/blob/48f6234713bc0da46a947c543c02a86adda080aa/jwcrypto/jwk.py#L947
The code entry is JWK.from_pem(private_key):
https://github.com/latchset/jwcrypto/blob/48f6234713bc0da46a947c543c02a86adda080aa/jwcrypto/jwk.py#L993
I would assume this code would work for you.
String pem = "a pem";
JSONWebKey jwk = JSONWebKey.build(pem);
jwk.kid = "foo";
If not, please re-open and provide some additional details so I can assist further.
Thanks.