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

meshtls: log errors parsing client certs #2467

Merged
merged 7 commits into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions linkerd/meshtls/rustls/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,26 @@ fn client_identity<I>(tls: &tokio_rustls::server::TlsStream<I>) -> Option<Client
let (_io, session) = tls.get_ref();
let certs = session.peer_certificates()?;
let c = certs.first().map(Certificate::as_ref)?;
let end_cert = webpki::EndEntityCert::try_from(c).ok()?;
let name: &str = end_cert.dns_names().ok()?.next().map(Into::into)?;
let end_cert = webpki::EndEntityCert::try_from(c)
.map_err(|error| tracing::warn!(%error, "Failed to parse client end-entity certificate"))
.ok()?;
let name: &str = end_cert
.dns_names()
.map_err(
|error| tracing::warn!(%error, "Failed to parse DNS names from client certificate"),
)
.ok()?
.next()
.map(Into::into)?;
if name == "*" {
// Wildcards can perhaps be handled in a future path...
return None;
}

name.parse().ok().map(ClientId)
name.parse()
.map_err(|error| tracing::warn!(%error, "Client certificate contained an invalid DNS name"))
.ok()
.map(ClientId)
}

// === impl ServerIo ===
Expand Down