From 8f920041cc5e7da1863218d1cf264c27c7f6a9c5 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 20 Mar 2023 20:38:57 -0400 Subject: [PATCH 1/2] Skip a test that hangs on OpenSSL 3.1.0 --- openssl/build.rs | 3 +++ openssl/src/error.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/openssl/build.rs b/openssl/build.rs index 5cddce90c2..5441606b28 100644 --- a/openssl/build.rs +++ b/openssl/build.rs @@ -50,6 +50,9 @@ fn main() { if version >= 0x3_00_00_00_0 { println!("cargo:rustc-cfg=ossl300"); } + if version >= 0x3_01_00_00_0 { + println!("cargo:rustc-cfg=ossl310"); + } } if let Ok(version) = env::var("DEP_OPENSSL_LIBRESSL_VERSION_NUMBER") { diff --git a/openssl/src/error.rs b/openssl/src/error.rs index 064d635234..e097ce6881 100644 --- a/openssl/src/error.rs +++ b/openssl/src/error.rs @@ -401,9 +401,12 @@ cfg_if! { #[cfg(test)] mod tests { + #[cfg(not(ossl310))] use crate::nid::Nid; #[test] + // Due to a bug in OpenSSL 3.1.0, this test can hang there. Skip for now. + #[cfg(not(ossl310))] fn test_error_library_code() { let stack = Nid::create("not-an-oid", "invalid", "invalid").unwrap_err(); let errors = stack.errors(); From 4ecaf691c889d03bb5699ef2fa1c01665e430593 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 20 Mar 2023 20:51:18 -0400 Subject: [PATCH 2/2] Fix LibreSSL version checking in openssl/ Previously it only did exact version matching -- different from how OpenSSL worked, and causing it to make many APIs exposed only on a single version of LibreSSL. This fixes that, and in the process identifies a bug in openssl-sys. --- openssl-sys/build/cfgs.rs | 3 +++ openssl/build.rs | 53 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/openssl-sys/build/cfgs.rs b/openssl-sys/build/cfgs.rs index d925d90ad7..960515f00f 100644 --- a/openssl-sys/build/cfgs.rs +++ b/openssl-sys/build/cfgs.rs @@ -31,6 +31,9 @@ pub fn get(openssl_version: Option, libressl_version: Option) -> Vec<& if libressl_version >= 0x2_09_01_00_0 { cfgs.push("libressl291"); } + if libressl_version >= 0x3_01_00_00_0 { + cfgs.push("libressl310"); + } if libressl_version >= 0x3_02_01_00_0 { cfgs.push("libressl321"); } diff --git a/openssl/build.rs b/openssl/build.rs index 5441606b28..0a974b33e6 100644 --- a/openssl/build.rs +++ b/openssl/build.rs @@ -16,8 +16,57 @@ fn main() { return; } - if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION") { - println!("cargo:rustc-cfg=libressl{}", v); + if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION_NUMBER") { + let version = u64::from_str_radix(&v, 16).unwrap(); + + if version >= 0x2_05_00_00_0 { + println!("cargo:rustc-cfg=libressl250"); + } + if version >= 0x2_05_01_00_0 { + println!("cargo:rustc-cfg=libressl251"); + } + if version >= 0x2_06_01_00_0 { + println!("cargo:rustc-cfg=libressl261"); + } + if version >= 0x2_07_00_00_0 { + println!("cargo:rustc-cfg=libressl270"); + } + if version >= 0x2_07_01_00_0 { + println!("cargo:rustc-cfg=libressl271"); + } + if version >= 0x2_07_03_00_0 { + println!("cargo:rustc-cfg=libressl273"); + } + if version >= 0x2_08_00_00_0 { + println!("cargo:rustc-cfg=libressl280"); + } + if version >= 0x2_09_01_00_0 { + println!("cargo:rustc-cfg=libressl291"); + } + if version >= 0x3_01_00_00_0 { + println!("cargo:rustc-cfg=libressl310"); + } + if version >= 0x3_02_01_00_0 { + println!("cargo:rustc-cfg=libressl321"); + } + if version >= 0x3_03_02_00_0 { + println!("cargo:rustc-cfg=libressl332"); + } + if version >= 0x3_04_00_00_0 { + println!("cargo:rustc-cfg=libressl340"); + } + if version >= 0x3_05_00_00_0 { + println!("cargo:rustc-cfg=libressl350"); + } + if version >= 0x3_06_00_00_0 { + println!("cargo:rustc-cfg=libressl360"); + } + if version >= 0x3_06_01_00_0 { + println!("cargo:rustc-cfg=libressl361"); + } + if version >= 0x3_07_00_00_0 { + println!("cargo:rustc-cfg=libressl370"); + } } if let Ok(vars) = env::var("DEP_OPENSSL_CONF") {