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

fix: allow example server http/1.0 ALPN. #193

Merged
merged 1 commit into from
Mar 7, 2023

Conversation

cpu
Copy link
Member

@cpu cpu commented Mar 7, 2023

Background

Prior to this branch the example/server.rs code built a Rustls ServerConfig that configured the alpn_protocols to accept HTTP/2 and HTTP/1.1. Notably, the protocol list did not include HTTP/1.0:

// Configure ALPN to accept HTTP/2, HTTP/1.1 in that order.
cfg.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];

This should have been uncovered by the tests/test.rs integration tests explicitly providing --http1.0 in the test curl invocations:

.arg("--http1.0")

Unfortunately it was hidden by an upstream bug in curl! Prior to v7.88.0 curl would send the HTTP1.1 ALPN ID even when --http1.0 was specified, and so our example server would work even without accepting HTTP1.0 ALPN. This was fixed in v7.88.0 and so our MacOS runners began to exhibit server test failures when they attempted to negotiate HTTP/1.0 ALPN with a server that didn't support it.

Fix

This commit updates the example server code to accept HTTP/1.0 ALPN, which in turn fixes the unit tests when run with Curl v7.88.0+. This should also help with other clients that didn't exhibit the same bug as curl did.

Prior to this commit the `example/server.rs` code built a Rustls
`ServerConfig` that configured the `alpn_protocols` to accept HTTP/2 and
HTTP/1.1. Notably, the protocol list did **not** include HTTP/1.0.

This should have been uncovered by the `tests/test.rs` integration
tests explicitly providing `--http1.0` in the test `curl` invocations,
but it was hidden by an upstream bug in curl! Prior to v7.88.0 curl
would send the HTTP1.1 ALPN ID even when `--http1.0` was specified[0],
and so our example server would work even without accepting HTTP1.0
ALPN.

This commit updates the example server code to accept HTTP/1.0 ALPN,
which in turn fixes the unit tests when run with Curl v7.88.0+. This
should also help with other clients that didn't exhibit the same bug as
curl did.

[0]: curl/curl@df856cb
@cpu cpu mentioned this pull request Mar 7, 2023
@djc djc merged commit 4bf725b into rustls:main Mar 7, 2023
@cpu cpu deleted the cpu-fix-http1.0-alpn branch March 7, 2023 17:01
@djc
Copy link
Member

djc commented Mar 7, 2023

Awesome, thanks!

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.

None yet

2 participants