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

Adds amplifying note about private key formats #1335

Merged
merged 2 commits into from
Sep 27, 2021
Merged

Adds amplifying note about private key formats #1335

merged 2 commits into from
Sep 27, 2021

Conversation

jmgilman
Copy link
Contributor

I'll leave this to the discretion of the maintainers on whether or not this is worth merging. The context is I had some code that relied on using TLS client certificate/keys and was occasionally running into issues where it would throw the "private key or certificate not found" error.

After further investigation, I found that, at least in one reproducible case, the client key was in the standard ECSDA PEM format:

-----BEGIN EC PRIVATE KEY-----
contents
-----END EC PRIVATE KEY-----

Obviously, the two calls to pkcs8_keys and rsa_private_keys shown here were both returning an empty vec. At face value, it's not obvious that this is going on under the hood and was confusing since I know that rustls supports these types of keys. The solution, in my case, was to simply convert the key to the PKCS#8 format in order to conform to what the crate was expecting. It's also worth noting that I was using curl as my sanity check which does support this key format out of the box - so there's even more chance of someone getting confused in this case.

An alternative solution is changing the error message to indicate this possibility - but I thought starting with the documentation was a cleaner approach (it would have saved me about an hour).

Copy link
Owner

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, seems good to me, thanks!

@seanmonstar seanmonstar enabled auto-merge (squash) September 27, 2021 18:24
@seanmonstar seanmonstar merged commit eb9e343 into seanmonstar:master Sep 27, 2021
@jmgilman jmgilman deleted the doc-priv-key branch September 27, 2021 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants