Skip to content

Allow client ALPN protocols to be specified at connection level #2429

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

Closed
wants to merge 6 commits into from

Conversation

CodeMan62
Copy link
Contributor

This PR implements issue #2260 by allowing ALPN protocols to be specified at the connection level instead of only in ClientConfig. This enables clients to reuse a single config for connections that differ only in their ALPN protocols.
The implementation adds new_with_alpn() methods to both client connection types while maintaining backward compatibility. The handshake code prioritizes connection-level protocols over config-level protocols when provided.
I have run tests locally all are going well no fails in issues

Copy link

codecov bot commented Apr 14, 2025

Codecov Report

Attention: Patch coverage is 97.29730% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.94%. Comparing base (841a160) to head (3406a11).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
rustls/src/client/client_conn.rs 97.14% 1 Missing ⚠️
rustls/src/quic.rs 95.45% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2429   +/-   ##
=======================================
  Coverage   95.94%   95.94%           
=======================================
  Files          94       94           
  Lines       22597    22657   +60     
=======================================
+ Hits        21680    21738   +58     
- Misses        917      919    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

I think this might make sense but would like to hear what @ctz thinks.

It will definitely need some test coverage.

) -> Result<Self, Error> {
let mut common_state = CommonState::new(Side::Client);
common_state.set_max_fragment_size(config.max_fragment_size)?;
common_state.protocol = proto;
common_state.enable_secret_extraction = config.enable_secret_extraction;
common_state.fips = config.fips();
let mut data = ClientConnectionData::new();
let mut data = ClientConnectionData::new(alpn_protocols);
Copy link
Member

Choose a reason for hiding this comment

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

I suggest this data is instead passed into hs::start_handshake, so it can be deallocated as soon as possible rather than kept for the full life of the connection.

Copy link
Member

Choose a reason for hiding this comment

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

@CodeMan62 Did I miss a detail, or is this feedback still unaddressed? I see alpn_protocols passed into the ClientConnectionData::new() call on L864 of client_conn.rs, in addition to the call to hs::start_handshake() on L873.

@CodeMan62
Copy link
Contributor Author

Hey @ctz, check the code changes in the last commit I think all the reviews you have given is resolved and let me know if any changes still required

@cpu
Copy link
Member

cpu commented Apr 16, 2025

I think all the reviews you have given is resolved and let me know if any changes still required

@CodeMan62 It looks like there are some build failures in CI to sort out.

@CodeMan62
Copy link
Contributor Author

@cpu I think all the CI should be sorted now. Can you check it, or let me know if any changes are required

@cpu
Copy link
Member

cpu commented Apr 17, 2025

Can you check it, or let me know if any changes are required

It looks like the clippy job is still failing.

@CodeMan62
Copy link
Contributor Author

@cpu clippy fixed!

@djc
Copy link
Member

djc commented Apr 17, 2025

If at all possible, please squash your commits into a single one.

@CodeMan62
Copy link
Contributor Author

If at all possible, please squash your commits into a single one.

I have not done that before but let me try

@CodeMan62 CodeMan62 force-pushed the connection-level-alpn branch from ef61f14 to 708752c Compare April 17, 2025 20:12
@CodeMan62
Copy link
Contributor Author

@djc it's done now you can merge it :)

@cpu
Copy link
Member

cpu commented Apr 17, 2025

it's done now you can merge it :)

Don't forget this feedback from Djc earlier too:

It will definitely need some test coverage.

@CodeMan62
Copy link
Contributor Author

@cpu So 2 things left here to add tests and to address 2nd feedback from @ctz right or i am missing something

@CodeMan62
Copy link
Contributor Author

@cpu, I did the work, first please check it.If all is well, then I will squash my commits into a single commit

@CodeMan62
Copy link
Contributor Author

CodeMan62 commented Apr 20, 2025

Clippy fixed 👍
Edit_1: Everything will be fixed by tomorrow:)

@CodeMan62
Copy link
Contributor Author

Hope everything fixed this time

@djc
Copy link
Member

djc commented Apr 23, 2025

Since there are still artifacts here of LLM-assisted coding and you have been less than forthcoming in responding to my question about this, I'm closing this PR and resubmitting as #2438. I will retain you as a co-author on the resulting commit.

@CodeMan62
Copy link
Contributor Author

Since there are still artifacts here of LLM-assisted coding and you have been less than forthcoming in responding to my question about this, I'm closing this PR and resubmitting as #2438. I will retain you as a co-author on the resulting commit.

Thanks for review I will work more on my skills

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.

4 participants