Comments (7)
Yeah we should fix the example code to deal with short writes for good form.
Though, in practice, there is really zero chance I think that that would ever happen with a real TCP sockets -- the server has written no data, so the write window is at least the MTU (the smallest of which is 68 bytes, and easily fits one alert). Though perhaps it's possible for protocols that upgrade to TLS from another protocol, like SMTP STARTTLS.
from rustls.
Maybe an AcceptedAlert::write_all(&mut io) -> io::Result<()>
would improve ergonomics for blocking usage?
from rustls.
I don't think blocking would be the concern since the underlying io is set to non-blocking and so would return ErrorKind::WouldBlock
and presumably early-return from the loop. This probably would be fine, since the async wrapper could do something roughly like the following:
return match alert.write(io) {
Err(e) if e.kind() == ErrorKind::WouldBlock => Poll::Pending,
other => Poll::Ready(other)
}
The loop in write
would likely never continue
in async usage because even a successful write is WouldBlock.
from rustls.
Maybe an AcceptedAlert::write_all(&mut io) -> io::Result<()> would improve ergonomics for blocking usage?
That's a good suggestion, thanks. I added a commit for this in #1868 and switched the acceptor example update commit to use it.
from rustls.
Fair point, we've been noticing this stuff in tokio-rustls: rustls/tokio-rustls#48.
from rustls.
Yeah we should fix the example code to deal with short writes for good form.
Here's a quick patch for the doc update & example's usage of AcceptedAlert::write
: #1868
It might make sense to do a more systematic evaluation of all the examples + writes as a follow up to make sure we address this holistically.
from rustls.
Good point @jbr - or we could change the behavior of write()
to do write_all()
, since as @ctz says this would never happen with a real TCP socket. So we would pay the price of possibly blocking an async executor in a very unlikely situation for the convenience of users not having to loop over the result.
from rustls.
Related Issues (20)
- 0.23 docs build is broken HOT 2
- optimize receiving data with TLS 1.2 and aes-128-gcm HOT 1
- optimize receiving data with TLS 1.3 and aes-256-gcm
- optimize server-side full handshakes for TLS 1.2 and 1.3 HOT 1
- Connection::dangerous_extract_secrets returns ConnectionTrafficSecrets::Aes128Gcm even when AES-256-GCM is negotiated
- Error: badRecordMac HOT 4
- Cipher suites configured through WebPkiServerVerifier::builder_with_provider is not working. Client hello contains more cipher suites then it configured. HOT 6
- rand_core::RngCore & CryptoRng support for CryptoProvider HOT 7
- expose more information in ClientHello HOT 4
- No common ciphersuit when FFDHE and ECDHE ciphersuites are available on server and client using TLS 1.2 HOT 4
- US Export control information HOT 4
- Support using rustls without using specific ring or aws-lc-rs apis HOT 2
- Feature request: a way to set/get default ticketer dynamically HOT 6
- Feature Request: Avoid panicking when ring and aws_lc_rs are both specified HOT 12
- Option to Relax SNI Host Name Validation for IP Addresses HOT 7
- unbuffered: B: `CapacityBuffer` for `output_tls.capacity()` HOT 9
- The support for "mipsel-unknown-linux-musl" has failed. HOT 2
- Io(Custom { kind: InvalidData, error: AlertReceived(HandshakeFailure) }) HOT 6
- Linux compilation is slow and seems unable to store compilation results HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rustls.