Skip to content

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

Merged
LucioFranco merged 2 commits intohyperium:masterfrom
domodwyer:bugfix/tls-handshake-crash
Oct 8, 2019
Merged

fix(transport): Avoid exit after bad TLS handshake#51
LucioFranco merged 2 commits intohyperium:masterfrom
domodwyer:bugfix/tls-handshake-crash

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,
			},
		),
	)
Co-Authored-By: Lucio Franco <luciofranco14@gmail.com>
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