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

rustls 0.22 support #103

Open
eric-seppanen opened this issue Dec 22, 2023 · 4 comments
Open

rustls 0.22 support #103

eric-seppanen opened this issue Dec 22, 2023 · 4 comments

Comments

@eric-seppanen
Copy link

I had a look at the reverted support for rustls 0.22, which should be unblocked now that tokio-rustls 0.25 has been released.

However, I found one change in rustls 0.22 that might force a breaking change to axum-server.

The problem lies here:

fn config_from_der(cert: Vec<Vec<u8>>, key: Vec<u8>) -> io::Result<ServerConfig> {
    // ...
}

The problem is that you can no longer build a ServerConfig directly from a private key in DER Vec<u8> form unless you know which flavor the key is. The expected input to a rustls ConfigBuilder is a PrivateKeyDer, which is defined as

pub enum PrivateKeyDer<'a> {
    /// An RSA private key
    Pkcs1(PrivatePkcs1KeyDer<'a>),
    /// A Sec1 private key
    Sec1(PrivateSec1KeyDer<'a>),
    /// A PKCS#8 private key
    Pkcs8(PrivatePkcs8KeyDer<'a>),
}

and there's no way to get a PrivateKeyDer from a Vec<u8>.

Is axum-server committed to this interface? It would be easier to implement this instead:

fn config_from_der(cert: Vec<PrivateKeyDer<'_>>, key: Vec<u8>) -> io::Result<ServerConfig> {
    // ...
}

but that would mean that the rustls and openssl interfaces diverge. config_from_pem can stay the way it is, because rustls_pemfile functions return PrivateKeyDer values.

@JustusFluegel
Copy link

I would like to add that the rustls and openssl interfaces where never quite the same in the first place so for me this wouldn't be that big of an issue, and since axum_server is pre-v1.0.0 we can probably justify a breaking change while moving to v0.7.0.

@eric-seppanen
Copy link
Author

I opened a draft PR in #106, if anyone else would like to have a look or test the changes.

It's a draft because I'm not sure if it's a good idea to land breaking changes since 0.6 just came out.

@diptanu
Copy link

diptanu commented Feb 24, 2024

Just looked into it @eric-seppanen make this a PR, it should be fine

@djc
Copy link

djc commented May 23, 2024

there's no way to get a PrivateKeyDer from a Vec<u8>.

Note that this got fixed in rustls-pki-types 1.4.0:

https://github.com/rustls/pki-types/releases/tag/v%2F1.4.0

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

No branches or pull requests

4 participants