jsonwebtoken icon indicating copy to clipboard operation
jsonwebtoken copied to clipboard

Does adding from_rsa_components() for EncodingKey make sense?

Open nlfiedler opened this issue 2 years ago • 2 comments

I'm presently using the rsa crate and creating a private/public key pair, then creating an EncodingKey from that. For now, it seems that I must convert the private key to a PEM encoded string and then create EncodingKey from that. I would like to skip that step if I may. I took a brief look at the code and it seems that DecodingKey and EncodingKey are built up differently, so it's not obvious to me if adding an from_rsa_components() to EncodingKey is a good idea or not. But it sure would be convenient. If you have any suggestions, I can give it a try myself and submit a PR.

nlfiedler avatar Dec 31 '22 17:12 nlfiedler

I'm not sure it makes sense. It's added to DecodingKey because you commonly get them as components (eg JWKs). It's much rarer for the encoding part.

Keats avatar Jan 02 '23 16:01 Keats

This is actually something that I would love to have, I'm aware that it's a rare use case but we do use the JWK format to represent our private keys. A from_rsa_components() or even from_jwk() would be greatly appreciated.

davidreis97 avatar May 30 '23 21:05 davidreis97