-
Notifications
You must be signed in to change notification settings - Fork 743
Simplify the simpleserver example by using rustls::Stream #2522
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2522 +/- ##
=======================================
Coverage 95.31% 95.31%
=======================================
Files 97 97
Lines 21514 21514
=======================================
Hits 20507 20507
Misses 1007 1007 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is OK. I think we don't generally want to encourage rustls::Stream
use, as it's pretty narrowly applicable and very hard to make a robust program with (especially for a server!) but actually this is mostly a comment about blocking IO and thread-per-client models.
Benchmark resultsInstruction countsSignificant differencesClick to expand
Other differencesClick to expand
Wall-timeSignificant differencesThere are no significant wall-time differences Other differencesClick to expand
Additional informationCheckout details:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
I agree with ctz's points that the Stream
abstraction's applicability is narrow, but having this example maintain symmetry with the simple client example that uses it makes sense.
Tested locally with tlscient-mio
(the simpleclient
example is too simple to use a non-system root CA without code changes)
$ RUST_LOG=rustls=trace cargo run --package rustls-examples --bin simpleserver -- test-ca/ecdsa-p256/end.fullchain test-ca/ecdsa-p256/end.key
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s
Running `target/debug/simpleserver test-ca/ecdsa-p256/end.fullchain test-ca/ecdsa-p256/end.key`
Received message from client: [71, 69, 84, 32, 47, 32, 72, 84, 84, 80, 47, 49, 46, 48, 13, 10, 72, 111, 115, 116, 58, 32, 108, 111, 99, 97, 108, 104, 111, 115, 116, 13, 10, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 32, 99, 108, 111, 115, 101, 13, 10, 65, 99, 99, 101, 112, 116, 45, 69, 110, 99, 111, 100]
$ cargo run --package rustls-examples --bin tlsclient-mio -- --http --port 4443 --cafile test-ca/ecdsa-p256/ca.cert localhost
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s
Running `target/debug/tlsclient-mio --http --port 4443 --cafile test-ca/ecdsa-p256/ca.cert localhost`
Hello from the serverEOF
Connection closed
Resolves #2520
This should hopefully make it easier to understand what the idiomatic way to use rustls in the most basic way (as a wrapper over an existing
impl Read+Write
) is.cc @cpu