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(transport): Avoid exit after bad TLS handshake #51

Merged
merged 2 commits into from
Oct 8, 2019
Merged

fix(transport): Avoid exit after bad TLS handshake #51

merged 2 commits into from
Oct 8, 2019

Conversation

domodwyer
Copy link
Contributor

Prevents the server exiting after a bad TLS handshake / error during
accept(). Instead the connection is dropped and the server continues to
serve new clients.

Previously an error would bubble up from the TLS library (tested with
rustls) and would cause:

	Server::builder()
	.rustls_tls(Identity::from_pem(&cert, &key))
	.clone()
	.serve(config.bind_addr(), AnExampleServer::new(endpoint))
	.await?;

to exit with:

	[src/main.rs:85] &e = Error(
		Server,
		Error(
			Accept,
			Custom {
				kind: InvalidData,
				error: CorruptMessage,
			},
		),
	)

This can be reproduced by dialling to a tonic server's socket and sending junk
until it crashes.

Unfortunately I'm a little unsure how to test this!

Prevents the server exiting after a bad TLS handshake / error during
accept(). Instead the connection is dropped and the server continues to
serve new clients.

Previously an error would bubble up from the TLS library (tested with
rustls) and cause hyper to exit with:

	[src/main.rs:85] &e = Error(
		Server,
		Error(
			Accept,
			Custom {
				kind: InvalidData,
				error: CorruptMessage,
			},
		),
	)
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

@LucioFranco LucioFranco changed the title transport: no crash after bad TLS handshake fix(transport): Avoid exit after bad TLS handshake Oct 8, 2019
@LucioFranco LucioFranco merged commit 412a0bd into hyperium:master Oct 8, 2019
@domodwyer
Copy link
Contributor Author

Thank you for building out tonic!

gRPC services are a fantastic way to incrementally introduce rust to an organisation, having a reliable crate to do so is critical - thanks for the time you've put into it.

@LucioFranco
Copy link
Member

@domodwyer I agree! Let me know if there is anything we can help with :)

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.

2 participants