From c0c03201d34c0ba830214996d4dc2ad419d04a5f Mon Sep 17 00:00:00 2001 From: Kikuo Emoto Date: Thu, 23 Nov 2023 15:52:06 +0900 Subject: [PATCH 1/3] feat: return trust anchor of verified path - `verify_cert::build_chain` returns the trust anchor of the verified path if it succeeds. `ChainOptions` needs to have another lifetime for the contents of `TrustAnchor` to return `TrustAnchor` without restricting lifetimes of other parameters. `TrustAnchor` carries the reference to the underlying DER representation so that users of this package can derive additional information from the results. `TrustAnchor` implements `Clone` to simplify lifetime management. The clone operation should not be expensive; four copies of references. The following public methods of `EndEntityCert` return the trust anchor of the verified path: - `verify_for_usage` - `verify_for_usage_with_policy_check` - `verify_is_valid_tls_server_cert` - `verify_is_valid_tls_client_cert` --- src/end_entity.rs | 62 ++++++++++----------- src/trust_anchor.rs | 99 ++++++++++++++++++++++++++++++--- src/verify_cert.rs | 38 +++++++------ tests/client_auth.rs | 2 +- tests/client_auth_revocation.rs | 2 +- tests/custom_ekus.rs | 2 +- tests/integration.rs | 16 +++--- 7 files changed, 152 insertions(+), 69 deletions(-) diff --git a/src/end_entity.rs b/src/end_entity.rs index fd44db58..7eecb0ab 100644 --- a/src/end_entity.rs +++ b/src/end_entity.rs @@ -77,16 +77,16 @@ impl<'a> EndEntityCert<'a> { } #[allow(clippy::too_many_arguments)] - fn verify_is_valid_cert( + fn verify_is_valid_cert<'b, 'c>( &self, - supported_sig_algs: &[&SignatureAlgorithm], - trust_anchors: &[TrustAnchor], - intermediate_certs: &[&[u8]], + supported_sig_algs: &'c [&SignatureAlgorithm], + trust_anchors: &'b [TrustAnchor<'b>], + intermediate_certs: &'c [&[u8]], time: Option