Skip to content

feat: add alpn_protocols for TlsConnector::connect_with #116

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

Merged
merged 1 commit into from
Jun 30, 2025

Conversation

yukiiiteru
Copy link
Contributor

Since rustls 0.23.27 added ClientConnection::new_with_alpn function, it is possible to set a different ALPN for each TLS connection, which is a very useful feature.

Given that there are already TlsConnector::connect and TlsConnector::connect_with functions, adding a new TlsConnector::connect_with_alpn function might be confusing, so I added a argument alpn_protocols: Option<Vec<Vec<u8>>> to the TlsConnector::connect_with function, which is expected to only affect a small number of users.

We also refer to the implementation of rustls. When the value of alpn_protocols is Some, we will use the it for current connection; when it is set to None, we will use the default alpn_protocols in the configuration. This makes TlsConnector::connect and TlsConnector::connect_with behave the same as before when alpn_protocols is None.

Reference: https://docs.rs/rustls/0.23.27/src/rustls/client/client_conn.rs.html#705-707

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

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

Thanks!

@djc djc merged commit 57f34ba into rustls:main Jun 30, 2025
6 checks passed
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.

3 participants