jwt-cli
jwt-cli copied to clipboard
Bug: Secret has to be in file format when encoding with RS256 etc
Seems strange to me - why treat the secret format differently for different algorithms? Aren't they orthogonal concerns?
Hi @alexfoxgill! I agree that it's not ideal. The problem is how we choose to parse the file (see here). We need to know if it's a pem or der file.
Happy to entertain better ideas!
I think a better way to determine whether it's a PEM or DER is by reading the first line. For example, if it starts with -----BEGIN RSA PRIVATE KEY-----
it's a PEM formatted RSA private key. Probably you can use the regex -----[A-Z ]+-----
to catch other types of keys too.
The other option, and probably more future proof is to attempt to parse it as a PEM first, and if that fails, parse as a DER file. If both fail, then it's invalid.
Unfortunately I don't have much time at the moment to work on this, but I'd be happy to review and PRs