Skip to content

Commit 319200a

Browse files
authored
Merge pull request #1851 from alex/libressl-versions
Fix LibreSSL version checking in openssl/
2 parents ead5e0a + 4ecaf69 commit 319200a

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

openssl-sys/build/cfgs.rs

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
3131
if libressl_version >= 0x2_09_01_00_0 {
3232
cfgs.push("libressl291");
3333
}
34+
if libressl_version >= 0x3_01_00_00_0 {
35+
cfgs.push("libressl310");
36+
}
3437
if libressl_version >= 0x3_02_01_00_0 {
3538
cfgs.push("libressl321");
3639
}

openssl/build.rs

+54-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,57 @@ fn main() {
1616
return;
1717
}
1818

19-
if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION") {
20-
println!("cargo:rustc-cfg=libressl{}", v);
19+
if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION_NUMBER") {
20+
let version = u64::from_str_radix(&v, 16).unwrap();
21+
22+
if version >= 0x2_05_00_00_0 {
23+
println!("cargo:rustc-cfg=libressl250");
24+
}
25+
if version >= 0x2_05_01_00_0 {
26+
println!("cargo:rustc-cfg=libressl251");
27+
}
28+
if version >= 0x2_06_01_00_0 {
29+
println!("cargo:rustc-cfg=libressl261");
30+
}
31+
if version >= 0x2_07_00_00_0 {
32+
println!("cargo:rustc-cfg=libressl270");
33+
}
34+
if version >= 0x2_07_01_00_0 {
35+
println!("cargo:rustc-cfg=libressl271");
36+
}
37+
if version >= 0x2_07_03_00_0 {
38+
println!("cargo:rustc-cfg=libressl273");
39+
}
40+
if version >= 0x2_08_00_00_0 {
41+
println!("cargo:rustc-cfg=libressl280");
42+
}
43+
if version >= 0x2_09_01_00_0 {
44+
println!("cargo:rustc-cfg=libressl291");
45+
}
46+
if version >= 0x3_01_00_00_0 {
47+
println!("cargo:rustc-cfg=libressl310");
48+
}
49+
if version >= 0x3_02_01_00_0 {
50+
println!("cargo:rustc-cfg=libressl321");
51+
}
52+
if version >= 0x3_03_02_00_0 {
53+
println!("cargo:rustc-cfg=libressl332");
54+
}
55+
if version >= 0x3_04_00_00_0 {
56+
println!("cargo:rustc-cfg=libressl340");
57+
}
58+
if version >= 0x3_05_00_00_0 {
59+
println!("cargo:rustc-cfg=libressl350");
60+
}
61+
if version >= 0x3_06_00_00_0 {
62+
println!("cargo:rustc-cfg=libressl360");
63+
}
64+
if version >= 0x3_06_01_00_0 {
65+
println!("cargo:rustc-cfg=libressl361");
66+
}
67+
if version >= 0x3_07_00_00_0 {
68+
println!("cargo:rustc-cfg=libressl370");
69+
}
2170
}
2271

2372
if let Ok(vars) = env::var("DEP_OPENSSL_CONF") {
@@ -50,6 +99,9 @@ fn main() {
5099
if version >= 0x3_00_00_00_0 {
51100
println!("cargo:rustc-cfg=ossl300");
52101
}
102+
if version >= 0x3_01_00_00_0 {
103+
println!("cargo:rustc-cfg=ossl310");
104+
}
53105
}
54106

55107
if let Ok(version) = env::var("DEP_OPENSSL_LIBRESSL_VERSION_NUMBER") {

openssl/src/error.rs

+3
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,12 @@ cfg_if! {
401401

402402
#[cfg(test)]
403403
mod tests {
404+
#[cfg(not(ossl310))]
404405
use crate::nid::Nid;
405406

406407
#[test]
408+
// Due to a bug in OpenSSL 3.1.0, this test can hang there. Skip for now.
409+
#[cfg(not(ossl310))]
407410
fn test_error_library_code() {
408411
let stack = Nid::create("not-an-oid", "invalid", "invalid").unwrap_err();
409412
let errors = stack.errors();

0 commit comments

Comments
 (0)