Skip to content

Commit

Permalink
Relax hard *ring* dep
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Mar 11, 2024
1 parent f4de3ba commit 9f58145
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
5 changes: 4 additions & 1 deletion rustls-platform-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cert-logging = ["base64"]
docsrs = ["jni", "once_cell"]

[dependencies]
rustls = { version = "0.23", default-features = false, features = ["std", "ring"] }
rustls = { version = "0.23", default-features = false, features = ["std"] }
log = { version = "0.4" }
base64 = { version = "0.21", optional = true } # Only used when the `cert-logging` feature is enabled.
jni = { version = "0.19", default-features = false, optional = true } # Only used during doc generation
Expand Down Expand Up @@ -64,6 +64,9 @@ security-framework-sys = { version = "2.4", features = ["OSX_10_14"] }
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["wincrypt", "winerror"] }

[dev-dependencies]
rustls = { version = "0.23", default-features = false, features = ["ring"] }

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
features = ["dbg", "docsrs"]
12 changes: 9 additions & 3 deletions rustls-platform-verifier/src/verification/android.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use jni::{
objects::{JObject, JValue},
strings::JavaStr,
Expand Down Expand Up @@ -44,7 +46,7 @@ pub struct Verifier {
/// Testing only: The root CA certificate to trust.
#[cfg(any(test, feature = "ffi-testing"))]
test_only_root_ca_override: Option<Vec<u8>>,
default_provider: CryptoProvider,
default_provider: Arc<CryptoProvider>,
}

impl Default for Verifier {
Expand Down Expand Up @@ -73,7 +75,9 @@ impl Verifier {
Self {
#[cfg(any(test, feature = "ffi-testing"))]
test_only_root_ca_override: None,
default_provider: rustls::crypto::ring::default_provider(),
default_provider: rustls::crypto::CryptoProvider::get_default()
.expect("rustls default CryptoProvider not set")
.clone(),
}
}

Expand All @@ -82,7 +86,9 @@ impl Verifier {
pub(crate) fn new_with_fake_root(root: &[u8]) -> Self {
Self {
test_only_root_ca_override: Some(root.into()),
default_provider: rustls::crypto::ring::default_provider(),
default_provider: rustls::crypto::CryptoProvider::get_default()
.expect("rustls default CryptoProvider not set")
.clone(),
}
}

Expand Down
12 changes: 9 additions & 3 deletions rustls-platform-verifier/src/verification/apple.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use super::log_server_cert;
use crate::verification::invalid_certificate;
use core_foundation::date::CFDate;
Expand Down Expand Up @@ -43,7 +45,7 @@ pub struct Verifier {
/// Testing only: The root CA certificate to trust.
#[cfg(any(test, feature = "ffi-testing", feature = "dbg"))]
test_only_root_ca_override: Option<Vec<u8>>,
default_provider: CryptoProvider,
default_provider: Arc<CryptoProvider>,
}

impl Verifier {
Expand All @@ -53,7 +55,9 @@ impl Verifier {
Self {
#[cfg(any(test, feature = "ffi-testing", feature = "dbg"))]
test_only_root_ca_override: None,
default_provider: rustls::crypto::ring::default_provider(),
default_provider: rustls::crypto::CryptoProvider::get_default()
.expect("rustls default CryptoProvider not set")
.clone(),
}
}

Expand All @@ -62,7 +66,9 @@ impl Verifier {
pub(crate) fn new_with_fake_root(root: &[u8]) -> Self {
Self {
test_only_root_ca_override: Some(root.into()),
default_provider: rustls::crypto::ring::default_provider(),
default_provider: rustls::crypto::CryptoProvider::get_default()
.expect("rustls default CryptoProvider not set")
.clone(),
}
}

Expand Down
11 changes: 8 additions & 3 deletions rustls-platform-verifier/src/verification/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use std::{
convert::TryInto,
mem::{self, MaybeUninit},
ptr::{self, NonNull},
sync::Arc,
};

use crate::verification::invalid_certificate;
Expand Down Expand Up @@ -419,7 +420,7 @@ pub struct Verifier {
/// Testing only: The root CA certificate to trust.
#[cfg(any(test, feature = "ffi-testing", feature = "dbg"))]
test_only_root_ca_override: Option<Vec<u8>>,
default_provider: CryptoProvider,
default_provider: Arc<CryptoProvider>,
}

impl Verifier {
Expand All @@ -429,7 +430,9 @@ impl Verifier {
Self {
#[cfg(any(test, feature = "ffi-testing", feature = "dbg"))]
test_only_root_ca_override: None,
default_provider: rustls::crypto::ring::default_provider(),
default_provider: rustls::crypto::CryptoProvider::get_default()
.expect("rustls default CryptoProvider not set")
.clone(),
}
}

Expand All @@ -438,7 +441,9 @@ impl Verifier {
pub(crate) fn new_with_fake_root(root: &[u8]) -> Self {
Self {
test_only_root_ca_override: Some(root.into()),
default_provider: rustls::crypto::ring::default_provider(),
default_provider: rustls::crypto::CryptoProvider::get_default()
.expect("rustls default CryptoProvider not set")
.clone(),
}
}

Expand Down

0 comments on commit 9f58145

Please sign in to comment.