Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Secret has to be in file format when encoding with RS256 etc #162

Open
alexfoxgill opened this issue Jan 10, 2022 · 3 comments
Open

Comments

@alexfoxgill
Copy link

Seems strange to me - why treat the secret format differently for different algorithms? Aren't they orthogonal concerns?

@mike-engel
Copy link
Owner

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!

@jarimayenburg
Copy link

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.

@mike-engel
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants