diff --git a/Cargo.lock b/Cargo.lock index 4d5cdb639..8d4df1942 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1326,7 +1326,6 @@ dependencies = [ "kvx", "libflate", "log", - "once_cell", "openidconnect", "openssl", "oso", diff --git a/Cargo.toml b/Cargo.toml index 6f891e19e..a207c2e32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,6 @@ kmip = { version = "0.4.3", package = "kmip-protocol", features = [ " kvx = { version = "0.9.3", features = ["macros"] } libflate = "2.1.0" log = "0.4" -once_cell = { version = "1.20.2", optional = true } openidconnect = { version = "2.5.1", optional = true, default-features = false } openssl = { version = "0.10", features = ["v110"] } oso = { version = "0.12", optional = true, default-features = false } @@ -78,7 +77,7 @@ syslog = "6.1.1" [features] default = ["multi-user", "hsm"] -hsm = ["backoff", "kmip", "once_cell", "cryptoki", "r2d2"] +hsm = ["backoff", "kmip", "cryptoki", "r2d2"] multi-user = [ "basic-cookies", "jmespatch/sync", diff --git a/src/commons/crypto/signing/signers/pkcs11/context.rs b/src/commons/crypto/signing/signers/pkcs11/context.rs index 0d2a274e2..64f006806 100644 --- a/src/commons/crypto/signing/signers/pkcs11/context.rs +++ b/src/commons/crypto/signing/signers/pkcs11/context.rs @@ -35,7 +35,7 @@ use cryptoki::{ slot::{Slot, SlotInfo, TokenInfo}, types::AuthPin, }; -use once_cell::sync::OnceCell; +use std::sync::OnceLock; use crate::commons::crypto::SignerError; @@ -80,7 +80,7 @@ impl ThreadSafePkcs11Context { /// RwLock'd HashMap for this. type Pkcs11ContextsByFileName = Arc>>; -static CONTEXTS: OnceCell = OnceCell::new(); +static CONTEXTS: OnceLock = OnceLock::new(); #[derive(Debug)] pub(super) struct Pkcs11Context { @@ -106,14 +106,10 @@ impl Pkcs11Context { pub fn get_or_load( lib_path: &Path, ) -> Result { - // Initialize the singleton map of PKCS#11 contexts. Failure here - // should be impossible or else so severe that panicking is - // all we can do. - let contexts = CONTEXTS - .get_or_try_init(|| -> Result { - Ok(Arc::new(RwLock::new(HashMap::new()))) - }) - .unwrap(); + // Initialize the singleton map of PKCS#11 contexts. + let contexts = CONTEXTS.get_or_init(|| { + Arc::new(RwLock::new(HashMap::new())) + }); // Use the file name of the library as the key into the map, if the // path represents a file.