From aa17d17cf16d4266f3ac331204b3e2c39d417c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Fern=C3=A1ndez=20L=C3=B3pez?= Date: Thu, 2 Dec 2021 13:45:50 +0200 Subject: [PATCH] Make accept_invalid_hostnames conditional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafael Fernández López --- Cargo.toml | 2 +- src/cosign/client.rs | 2 +- src/registry.rs | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 902a864bac..73044a4143 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ anyhow = "1.0.44" async-trait = "0.1.51" base64 = "0.13.0" ecdsa = { version = "0.12.4", features = ["verify", "pem", "der", "pkcs8"] } -oci-distribution = { version = "0.7.0", default-features = false } +oci-distribution = { version = "0.8.1", default-features = false } olpc-cjson = "0.1.1" p256 = {version = "0.9.0", features = ["ecdsa-core"]} serde_json = "1.0.68" diff --git a/src/cosign/client.rs b/src/cosign/client.rs index dcff794153..9d6cb95803 100644 --- a/src/cosign/client.rs +++ b/src/cosign/client.rs @@ -221,7 +221,7 @@ mod tests { let image = "docker.io/busybox:latest"; let image_digest = String::from("sha256:f3cfc9d0dbf931d3db4685ec659b7ac68e2a578219da4aae65427886e649b06b"); - let expected_image = "docker.io/busybox:sha256-f3cfc9d0dbf931d3db4685ec659b7ac68e2a578219da4aae65427886e649b06b.sig".parse().unwrap(); + let expected_image = "docker.io/library/busybox:sha256-f3cfc9d0dbf931d3db4685ec659b7ac68e2a578219da4aae65427886e649b06b.sig".parse().unwrap(); let mock_client = MockOciClient { fetch_manifest_digest_response: Some(Ok(image_digest.clone())), pull_response: None, diff --git a/src/registry.rs b/src/registry.rs index d680acbced..027da73224 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -111,6 +111,7 @@ pub struct ClientConfig { pub protocol: ClientProtocol, /// Accept invalid hostname. Defaults to false + #[cfg(feature = "native-tls")] pub accept_invalid_hostnames: bool, /// Accept invalid certificates. Defaults to false @@ -125,6 +126,7 @@ impl Default for ClientConfig { fn default() -> Self { ClientConfig { protocol: ClientProtocol::Https, + #[cfg(feature = "native-tls")] accept_invalid_hostnames: false, accept_invalid_certificates: false, extra_root_certificates: Vec::new(), @@ -137,6 +139,7 @@ impl From for oci_distribution::client::ClientConfig { oci_distribution::client::ClientConfig { protocol: oci_distribution::client::ClientProtocol::Https, accept_invalid_certificates: config.accept_invalid_certificates, + #[cfg(feature = "native-tls")] accept_invalid_hostnames: config.accept_invalid_hostnames, extra_root_certificates: config .extra_root_certificates