Skip to content

Commit 27587f5

Browse files
authored
dns-name: Remove webpki dependency (#1316)
The `dns::Name` type is backed by `webpki::DNSName`; and the `webpki` crate has a dependency on `ring`. As we setup to support alternate cryptographic implementations, we don't want to incur this dependency for such a simple type that only validates DNS-like names. This change copies the `webpki::DNSName` and `webpki::DNSNameRef` types as `dns::Name` and `dns::NameRef` (preserving copyright information). Name parsing is simplified, as we don't need to handle wildcards with these types. Furthermore, this change updates the various identity-type wrapper types to implement `Deref` so that `dns::Name::as_str` and `dns::Name::as_bytes` are available implicitly.
1 parent 82d2c40 commit 27587f5

File tree

15 files changed

+352
-119
lines changed

15 files changed

+352
-119
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,6 @@ version = "0.1.0"
879879
dependencies = [
880880
"thiserror",
881881
"untrusted",
882-
"webpki",
883882
]
884883

885884
[[package]]

linkerd/app/gateway/src/gateway.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ where
155155
{
156156
if let Some(by) = fwd_by(forwarded) {
157157
tracing::info!(%forwarded);
158-
if by == local_id.as_ref() {
158+
if by == local_id.as_str() {
159159
return Box::pin(future::err(GatewayLoop.into()));
160160
}
161161
}

linkerd/app/inbound/src/http/set_identity_header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
.and_then(|tls| match tls {
4444
tls::ServerTls::Established { client_id, .. } => {
4545
client_id.as_ref().and_then(|id| {
46-
match http::HeaderValue::from_str(id.as_ref().as_ref()) {
46+
match http::HeaderValue::from_str(id.as_str()) {
4747
Ok(v) => Some(v),
4848
Err(error) => {
4949
tracing::warn!(%error, "identity not a valid header value");

linkerd/app/inbound/src/policy/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ impl AllowPolicy {
144144
..
145145
}) = tls
146146
{
147-
if identities.contains(id.as_ref())
148-
|| suffixes.iter().any(|s| s.contains(id.as_ref()))
147+
if identities.contains(id.as_str())
148+
|| suffixes.iter().any(|s| s.contains(id.as_str()))
149149
{
150150
return Ok(Permit::new(self.dst, &*server, authz));
151151
}

linkerd/app/outbound/src/http/require_id_header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ where
8686
if let Some(require_id) = Self::extract_id(&mut request) {
8787
match self.tls.as_ref() {
8888
Conditional::Some(tls::ClientTls { server_id, .. }) => {
89-
if require_id != *server_id.as_ref() {
89+
if require_id != **server_id {
9090
debug!(
9191
required = %require_id,
9292
found = %server_id,

linkerd/dns/name/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ publish = false
99
[dependencies]
1010
thiserror = "1.0"
1111
untrusted = "0.7"
12-
webpki = "0.21"

linkerd/dns/name/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
mod name;
55
mod suffix;
66

7-
pub use self::name::{InvalidName, Name};
7+
pub use self::name::{InvalidName, Name, NameRef};
88
pub use self::suffix::Suffix;

0 commit comments

Comments
 (0)