-
Notifications
You must be signed in to change notification settings - Fork 33
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
Rustls 0.21.5, client verifier CRL support. #324
Conversation
This failure is nightly clippy saying:
Ctz spotted that:
|
3766a91
to
2f92ff3
Compare
bf791cd
to
536ddce
Compare
536ddce
to
1e79665
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm perhaps a bit compromised on this, but i think this looks good.
reviewing this makes me think the rustls api for choosing between mandatory and optional client auth is a bit inflexible. but that's not an issue for here.
@jsha Is this a PR you would be interested in reviewing? Since both Ctz and myself contributed code it would be nice to have an independent set of eyes on it if you're available. |
Yep! Planning to check it out a little now and a little tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks great, thanks so much for working on this.
I agree with ctz that the upstream API might be better; maybe it would even benefit from a builder pattern? E.g.:
let client_cert_verifier = VerifierBuilder::new().with_crl(xyz).allow_anonymous();
let client_cert_verifier2 = VerifierBuilder::new().with_crl(xyz).require_certificate();
In terms of how this would be used, I'd expect the CRL(s) to be updated with some frequency, but the comments here and on rustls/rustls#1326 don't make it immediately clear how to do that. Is the idea that you're always using the Acceptor API, and each time you select / build a ServerConfig, you provide it with a client cert verifier that is provided with the most up-to-date CRLs you've got?
Thanks for the review! Much appreciated. I'll work through the feedback ASAP.
That does seem better. I think my preference would be to try and land this branch as-is and then look at iterating on the Rustls-side API as part of the next release since I suspect it will be a breaking change and we're queuing a few of those for a 0.22.x release. Does that seem reasonable or would you prefer we hold this work to avoid reworking the API twice on the ffi side?
Yes I think that's the best approach with the existing implementation 👍 My original goal was to have the verifier configured with a I suspect there's room for improvements here but it was starting to feel like the energy folks had to dedicate to this effort was waning and the simpler approach was something we could get out the door. Does that make sense? I'm hopeful there's still utility to this feature even with that limitation in mind. |
Yep, very agree on this.
Sounds good. This does mean the server needs to know in advance all the CRLs it could possibly expect to see in any client certificate, but I think that is probably a reasonable requirement given how I expect client certificates are used in practice. |
* Rustls 0.21.0 -> 0.21.5 * Webpki 0.22 -> Rustls webpki 0.101.0 * Rustls pemfile 0.2.1 -> 1.0.3
This commit renames the `rustls_client_cert_verifier` and `rustls_client_cert_verifier_optional` types to better match their upstream Rustls equivalents: `rustls_allow_any_authenticated_client_verifier` and `rustls_allow_any_anonymous_or_authenticated_client_verifier`. While wordier, these names are easier to understand and to map back to their Rust equivalents. Associated functions (`_new` and `_free`) are updated to match the new naming scheme.
1e79665
to
d80c42b
Compare
Oops, forgot to regenerate the I'll update + push. |
d80c42b
to
2dcfc27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! Almost there.
2dcfc27
to
3b6208f
Compare
D'oh. |
3b6208f
to
23f81c5
Compare
This commit reworks both the `rustls_allow_any_authenticated_client_verifier` and the `rustls_allow_any_anonymous_or_authenticated_client_verifier` structs to use a separate builder pattern. This enables optionally providing the builder CRLs from PEM files. Afterwards the intermediate builder can be turned into the standard `const *` verifiers to provide to the client configuration.
This commit updates the `tests/server.c` example program to support reading one or more CRLs from a single PEM encoded CRL file, provided via `AUTH_CRL`. This option is only processed when the server is performing mandatory client authentication (e.g. `AUTH_CERT` was provided).
This commit adds a simple test CRL (`testdata/test.crl.pem`) that lists the `testdata/localhost/cert.pem` certificate as revoked, but _not_ the `testdata/example.com/cert.pem` certificate. The `client-server.py` integration test driver is then updated with a suite that will start the server binary in a mode that requires mTLS, and that loads the test crl. Two connection attempts are made with the client binary: one using the `example.com` client cert that isn't expected to error, and one using the `localhost` client cert that _is_ expected to error (since it's revoked).
23f81c5
to
4e0f63f
Compare
I regenerated with 0.24.3 and on the next run CI was using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎸
I can open a PR updating the Edit: and thanks again for the reviews/help! |
|
chore: ignore clion/jetbrains dir, venv dir.
Small quality of life improvement for developers using clion and a venv for the Python tests.
deps: update rustls ecosystem dependencies.
Brings in the latest Rustls and supporting libraries.
cipher: rename verifier types to match upstream.
This commit renames the
rustls_client_cert_verifier
andrustls_client_cert_verifier_optional
types to better match their upstream Rustls equivalents:rustls_allow_any_authenticated_client_verifier
andrustls_allow_any_anonymous_or_authenticated_client_verifier
. While wordier, these names are easier to understand and to map back to their Rust equivalents.Associated functions (
_new
and_free
) are updated to match the new naming scheme.cipher: client cert verifier w/ CRLs support.
This commit reworks both the
rustls_client_cert_verifier_optional
andrustls_client_cert_verifier
structs to use a separate builder pattern. This enables optionally providing the builder CRLs from PEM files. Afterwards the intermediate builder can be turned into the standardconst *
verifiers to provide to the client configuration.Thanks to @ctz for suggesting this approach and sketching it out with me in a draft branch I've tided up and extended here.
server: support reading CRL PEM for client auth.
This commit updates the
tests/server.c
example program to support reading one or more CRLs from a single PEM encoded CRL file, provided viaAUTH_CRL
. This option is only processed when the server is performing mandatory client authentication (e.g.AUTH_CERT
was provided).tests: add CRL mTLS test.
This commit adds a simple test CRL (
testdata/test.crl.pem
) that lists thetestdata/localhost/cert.pem
certificate as revoked, but not thetestdata/example.com/cert.pem
certificate.The
client-server.py
integration test driver is then updated with a suite that will start the server binary in a mode that requires mTLS, and that loads the test crl. Two connection attempts are made with the client binary: one using theexample.com
client cert that isn't expected to error, and one using thelocalhost
client cert that is expected to error (since it's revoked).