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

Accept EC PRIVATE KEY items in PEM files. #909

Merged
merged 2 commits into from
Jan 24, 2024
Merged

Accept EC PRIVATE KEY items in PEM files. #909

merged 2 commits into from
Jan 24, 2024

Conversation

partim
Copy link
Member

@partim partim commented Nov 24, 2023

This PR adds support for private keys marked as “EC PRIVATE KEY“ in the PEM files for TLS server configuration.

Fixes #908.

@partim partim requested review from DRiKE, density215 and a team and removed request for DRiKE and density215 November 24, 2023 11:42
@@ -96,7 +96,7 @@ fn read_key(key_path: &Path) -> Result<PrivateKey, ExitError> {
})?;

let bits = match item {
RSAKey(bits) | PKCS8Key(bits) => bits,
RSAKey(bits) | PKCS8Key(bits) | ECKey(bits) => bits,
Copy link
Member

Choose a reason for hiding this comment

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

Is this tested anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not currently, no.

Copy link
Member

Choose a reason for hiding this comment

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

I tested it locally like so:

$ openssl ecparam -name prime256v1 -genkey -noout -out /tmp/ec-private-key.pem
$ openssl ec -in /tmp/ec-private-key.pem -pubout -out /tmp/ec-public-key.pem
$ openssl req -new -x509 -key /tmp/ec-private-key.pem -out /tmp/ec-cert.pem -days 360
$ routinator -vvv server --http-tls 127.0.0.1:8443 --http-tls-cert /tmp/ec-cert.pem --http-tls-key /tmp/ec-private-key.pem 

With Routinator 0.13.0 that resulted in an error:

[ERROR] TLS key file '/tmp/ec-private-key.pem' does not contain any usable keys.

With this PR there was no error and openssl shows the EC key in use:

$ true | openssl s_client -connect localhost:8443 2>&1 | openssl x509 -noout -text | grep Algorithm
        Signature Algorithm: ecdsa-with-SHA256
            Public Key Algorithm: id-ecPublicKey
    Signature Algorithm: ecdsa-with-SHA256

@partim partim merged commit c741608 into main Jan 24, 2024
10 checks passed
@partim partim deleted the http-server-ec-keys branch January 24, 2024 16:27
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.

Header/footer lines of EC TLS key files
2 participants