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

feat(transport): Add support client mTLS #77

Merged
merged 1 commit into from
Oct 22, 2019

Conversation

jen20
Copy link
Collaborator

@jen20 jen20 commented Oct 16, 2019

This commit adds a simple API for specifying the TLS certificate a gRPC client will present (via the same Identity wrapper as a server cert is configured). It also adds an API to specify which CA certificate client TLS certificates will be validated against for servers.

To demonstrate usage, a new example tls_client_auth is added. In order to implement this, new test certificates are added to the data directory of tonic-examples. Currently only one of the two added client certificates is used, the other is intended for future work but since it was issued by the same CA, it's helpful to add it now.

Some of the code for loading certificates and private keys previously existed in the TlsAcceptor class - this has been factored out to a new module so it can be reused by TlsConnector also.

Currently this is only implemented for rustls - an OpenSSL implementation will follow on this PR shortly.

@jen20 jen20 force-pushed the jen20/mutual-tls-simple-config branch 2 times, most recently from 45e9c70 to 9650642 Compare October 17, 2019 08:17
@jen20 jen20 marked this pull request as ready for review October 17, 2019 08:50
@jen20 jen20 force-pushed the jen20/mutual-tls-simple-config branch 2 times, most recently from 4d794e8 to a9e10e4 Compare October 17, 2019 12:29
@jen20 jen20 force-pushed the jen20/mutual-tls-simple-config branch from a9e10e4 to 1d9f746 Compare October 20, 2019 17:11
};
let mut client_root_cert_store = tokio_rustls::rustls::RootCertStore::empty();
match client_root_cert_store.add_pem_file(&mut cert) {
Err(_) => return Err(Box::new(TlsError::CertificateParseError)),
Copy link
Member

Choose a reason for hiding this comment

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

do we want to attach the error message here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll update this - we likely do want the error message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only kidding... the error type is ().

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.

LGTM just left a few questions inline.

This commit adds a simple API for specifying the TLS certificate a GRPC
client will present (via the same `Identity` wrapper as a server cert is
configured). It also adds an API to specify which CA certificate client
TLS certificates will be validated against for servers.

To demonstrate usage, a new example `tls_client_auth` is added, using
OpenSSL for the client and Rustls for the server.
@jen20 jen20 force-pushed the jen20/mutual-tls-simple-config branch from 1d9f746 to 5e9a073 Compare October 22, 2019 20:53
@jen20
Copy link
Collaborator Author

jen20 commented Oct 22, 2019

OK, I think these are all resolved!

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.

Fantastic! Thank you! We will def showcase this with the next release 😄

@LucioFranco LucioFranco changed the title Add simple configuration API for configuring Client TLS certificates feat(transport): Add support client mTLS Oct 22, 2019
@LucioFranco LucioFranco merged commit 335a373 into hyperium:master Oct 22, 2019
@jen20 jen20 deleted the jen20/mutual-tls-simple-config branch October 22, 2019 21:00
rabbitinspace pushed a commit to satelit-project/tonic that referenced this pull request Jan 1, 2020
This commit adds a simple API for specifying the TLS certificate a GRPC
client will present (via the same `Identity` wrapper as a server cert is
configured). It also adds an API to specify which CA certificate client
TLS certificates will be validated against for servers.
brentalanmiller pushed a commit to brentalanmiller/tonic that referenced this pull request Oct 6, 2023
* Add regression test for hyperium#77

* Fix handshake alert

* Fix style
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