Skip to content

Commit

Permalink
chore(server): Reduce unnecessary value clone
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Jan 8, 2025
1 parent 48b970b commit 5173b5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions tonic/src/transport/server/service/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub(crate) struct TlsAcceptor {

impl TlsAcceptor {
pub(crate) fn new(
identity: Identity,
client_ca_root: Option<Certificate>,
identity: &Identity,
client_ca_root: Option<&Certificate>,
client_auth_optional: bool,
ignore_client_order: bool,
) -> Result<Self, crate::BoxError> {
Expand All @@ -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 {
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tonic/src/transport/server/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ impl ServerTlsConfig {

pub(crate) fn tls_acceptor(&self) -> Result<TlsAcceptor, crate::BoxError> {
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,
)
Expand Down

0 comments on commit 5173b5f

Please sign in to comment.