From 5173b5fd87ebcfed38d6bb38bd7557232f1f199d Mon Sep 17 00:00:00 2001 From: tottoto Date: Wed, 8 Jan 2025 19:35:53 +0900 Subject: [PATCH] chore(server): Reduce unnecessary value clone --- tonic/src/transport/server/service/tls.rs | 8 ++++---- tonic/src/transport/server/tls.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tonic/src/transport/server/service/tls.rs b/tonic/src/transport/server/service/tls.rs index 874be03c9..0a24d9482 100644 --- a/tonic/src/transport/server/service/tls.rs +++ b/tonic/src/transport/server/service/tls.rs @@ -19,8 +19,8 @@ pub(crate) struct TlsAcceptor { impl TlsAcceptor { pub(crate) fn new( - identity: Identity, - client_ca_root: Option, + identity: &Identity, + client_ca_root: Option<&Certificate>, client_auth_optional: bool, ignore_client_order: bool, ) -> Result { @@ -30,7 +30,7 @@ impl TlsAcceptor { None => builder.with_no_client_auth(), Some(cert) => { let mut roots = RootCertStore::empty(); - roots.add_parsable_certificates(convert_certificate_to_pki_types(&cert)?); + roots.add_parsable_certificates(convert_certificate_to_pki_types(cert)?); let verifier = if client_auth_optional { WebPkiClientVerifier::builder(roots.into()).allow_unauthenticated() } else { @@ -41,7 +41,7 @@ impl TlsAcceptor { } }; - let (cert, key) = convert_identity_to_pki_types(&identity)?; + let (cert, key) = convert_identity_to_pki_types(identity)?; let mut config = builder.with_single_cert(cert, key)?; config.ignore_client_order = ignore_client_order; diff --git a/tonic/src/transport/server/tls.rs b/tonic/src/transport/server/tls.rs index 4a6d52071..92da18347 100644 --- a/tonic/src/transport/server/tls.rs +++ b/tonic/src/transport/server/tls.rs @@ -66,8 +66,8 @@ impl ServerTlsConfig { pub(crate) fn tls_acceptor(&self) -> Result { TlsAcceptor::new( - self.identity.clone().unwrap(), - self.client_ca_root.clone(), + self.identity.as_ref().unwrap(), + self.client_ca_root.as_ref(), self.client_auth_optional, self.ignore_client_order, )