Skip to content

feat: add alpn_protocols for TlsConnector::connect_with - #116

Merged
djc merged 1 commit into
rustls:mainfrom
yukiiiteru:main
Jun 30, 2025
Merged

djc merged 1 commit into
rustls:mainfrom
yukiiiteru:main

Conversation

@yukiiiteru

Copy link
Copy Markdown

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

Comment thread src/lib.rs Resolved

@djc djc left a comment

Copy link
Copy Markdown
Member

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
@ADD-SP ADD-SP mentioned this pull request Sep 17, 2025
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