Skip to content

Conversation

francislavoie
Copy link
Member

@francislavoie francislavoie commented Sep 25, 2024

A user recently pointed out that they were misled because they tried to use an encrypted private key, which we don't support (see #4873).

I chose to read the first 40 characters of the PEM to see if it has ENCRYPTED to guess whether it was encrypted. I chose 40 because the length of the ASCII armor -----BEGIN ENCRYPTED PRIVATE KEY----- is 37, just a rough estimate of the input. I don't know how EC encrypted keys look but I assume it also uses ENCRYPTED in the header?

Before this, the error was:

Error: loading initial config: loading new config: loading http app module: provision http: getting tls app: loading tls app module: provision tls: loading certificates: tls: failed to parse private key

Now:

Error: loading initial config: loading new config: loading http app module: provision http: getting tls app: loading tls app module: provision tls: loading certificates: encrypted private keys are not supported; please decrypt the key first

@francislavoie francislavoie added the bug 🐞 Something isn't working label Sep 25, 2024
@francislavoie francislavoie requested a review from mholt September 25, 2024 07:59
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Nice idea -- thanks!

@mholt mholt merged commit 9dda8fb into master Sep 25, 2024
33 checks passed
@mholt mholt deleted the better-error-with-encrypted-private-key branch September 25, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants