Skip to content

Conversation

@djc
Copy link
Member

@djc djc commented Nov 21, 2025

@howardjohn please take a look if this can address your use case. If so, could you add some test coverage for it?

(I do wonder if at this point it would be easier to just address the non-TLS input case more directly...)

Fixes #146.

@djc djc requested review from cpu, ctz and quininer November 21, 2025 08:55
@ctz
Copy link
Member

ctz commented Nov 21, 2025

I don't mind adopting this as a possibility, but definitely needs to be defend with tests. (And, ideally the referenced example code is executed to ensure it behaves as desired.)

@howardjohn
Copy link

Thanks @djc !! I added tests and a bit more in #148

}

/// Configure whether to send a TLS alert on failure.
pub fn send_alert(mut self, send: bool) -> Self {
Copy link
Member Author

Choose a reason for hiding this comment

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

@howardjohn what is the purpose of this? It doesn't make sense to me. If send_alert is true, we've sent the alert before this is reachable. If send_alert is false, I think you can only call this without taking out either the io or the alert, and there's no way you can actually check what the server received, I think?


match alert.write(&mut SyncWriteAdapter { io, cx }) {
Ok(0) => return Poll::Ready(Ok(())),
Ok(_) => continue,
Copy link
Member Author

Choose a reason for hiding this comment

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

Pretty sure this is wrong. In case of a partial write, just calling alert.write() again is wrong, since it'll duplicate the parts of the alert that were sent previously.

(Presumably it would be exceedingly rare to get a partial write, but still...)

LazyConfigAcceptor::new(rustls::server::Acceptor::default(), sstream).send_alert(false);
tokio::pin!(acceptor);

let Ok(accept_result) = time::timeout(Duration::from_secs(3), acceptor.as_mut()).await else {
Copy link
Member Author

Choose a reason for hiding this comment

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

@howardjohn you added a bunch of timeouts here which don't really seem necessary? This is a pretty controlled environment, so it feels excessive?

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.

Documented solution to return HTTP errors to plaintext clients broke

4 participants