From 9de3794474d8440e80d362531f82d0d9ce07c22a Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 6 Jul 2024 19:42:35 -0400 Subject: [PATCH] Initialize OpenSSL in MD constructors --- openssl/src/hash.rs | 1 + openssl/src/md.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/openssl/src/hash.rs b/openssl/src/hash.rs index 01d7097b09..f2f2698f3e 100644 --- a/openssl/src/hash.rs +++ b/openssl/src/hash.rs @@ -70,6 +70,7 @@ impl MessageDigest { /// /// [`EVP_get_digestbynid`]: https://www.openssl.org/docs/manmaster/crypto/EVP_DigestInit.html pub fn from_nid(type_: Nid) -> Option { + ffi::init(); unsafe { let ptr = ffi::EVP_get_digestbynid(type_.as_raw()); if ptr.is_null() { diff --git a/openssl/src/md.rs b/openssl/src/md.rs index 08e4aacf3e..a9df311400 100644 --- a/openssl/src/md.rs +++ b/openssl/src/md.rs @@ -80,6 +80,7 @@ impl Md { /// Returns the `Md` corresponding to an [`Nid`]. #[corresponds(EVP_get_digestbynid)] pub fn from_nid(type_: Nid) -> Option<&'static MdRef> { + ffi::init(); unsafe { let ptr = ffi::EVP_get_digestbynid(type_.as_raw()); if ptr.is_null() { @@ -100,6 +101,7 @@ impl Md { algorithm: &str, properties: Option<&str>, ) -> Result { + ffi::init(); let algorithm = CString::new(algorithm).unwrap(); let properties = properties.map(|s| CString::new(s).unwrap());