diff --git a/boring-sys/src/lib.rs b/boring-sys/src/lib.rs index c821b3e5..094221ff 100644 --- a/boring-sys/src/lib.rs +++ b/boring-sys/src/lib.rs @@ -48,18 +48,7 @@ pub const fn ERR_GET_REASON(l: c_uint) -> c_int { } pub fn init() { - use std::ptr; - use std::sync::Once; - - // explicitly initialize to work around https://github.com/openssl/openssl/issues/3505 - static INIT: Once = Once::new(); - - let init_options = OPENSSL_INIT_LOAD_SSL_STRINGS; - - INIT.call_once(|| { - assert_eq!( - unsafe { OPENSSL_init_ssl(init_options.try_into().unwrap(), ptr::null_mut()) }, - 1 - ) - }); + unsafe { + CRYPTO_library_init(); + } } diff --git a/boring/src/error.rs b/boring/src/error.rs index fdc3ba9e..9cdc878b 100644 --- a/boring/src/error.rs +++ b/boring/src/error.rs @@ -182,6 +182,12 @@ impl Error { } } + /// Returns the raw OpenSSL error constant for the library reporting the + /// error. + pub fn library_code(&self) -> libc::c_int { + ffi::ERR_GET_LIB(self.code) + } + /// Returns the name of the function reporting the error. pub fn function(&self) -> Option<&'static str> { unsafe { @@ -206,6 +212,11 @@ impl Error { } } + /// Returns the raw OpenSSL error constant for the reason for the error. + pub fn reason_code(&self) -> libc::c_int { + ffi::ERR_GET_REASON(self.code) + } + /// Returns the name of the source file which encountered the error. pub fn file(&self) -> &'static str { unsafe { @@ -235,12 +246,14 @@ impl fmt::Debug for Error { if let Some(library) = self.library() { builder.field("library", &library); } + builder.field("library_code", &self.library_code()); if let Some(function) = self.function() { builder.field("function", &function); } if let Some(reason) = self.reason() { builder.field("reason", &reason); } + builder.field("reason_code", &self.reason_code()); builder.field("file", &self.file()); builder.field("line", &self.line()); if let Some(data) = self.data() {