Skip to content

How can I sign a JWT with RS256 using PS256 private key #637

Closed Locked Answered by panva
maximilianfixl asked this question in Q&A
Discussion options

You must be logged in to vote

I can load the keys and sign the jwt using PS256 algorithm, but I can't load the keys with PS256 algorithm, convert them to RS256 algorithm and sign the jwt. How can I achieve this? Thanks a lot for your help in advance!

Here the private and public keys are loaded using RSASSA-PSS and casted to RSAPrivateKey and RSAPublicKey respectively.

You've generated an RSASSA-PSS key, it cannot be used for RS256, at least not in Node.js, there's no manipulation in the crypto module you could do to drop/change the key's parameters.

If you want a key that's usable for both RS256 and PS256 use this

-openssl req -newkey rsa-pss -new -nodes -x509 -days 3650 -pkeyopt rsa_keygen_bits:4096 -sigopt rsa_p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@maximilianfixl
Comment options

Answer selected by maximilianfixl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants