Skip to content

Commit e534b10

Browse files
coolreader18youknowone
authored andcommitted
Fix build with ossl1
1 parent 0785cc5 commit e534b10

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

stdlib/build.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
fn main() {
22
println!(r#"cargo::rustc-check-cfg=cfg(osslconf, values("OPENSSL_NO_COMP"))"#);
3-
println!("cargo::rustc-check-cfg=cfg(ossl101)");
4-
println!("cargo::rustc-check-cfg=cfg(ossl102)");
5-
println!("cargo::rustc-check-cfg=cfg(ossl110)");
6-
println!("cargo::rustc-check-cfg=cfg(ossl110g)");
7-
println!("cargo::rustc-check-cfg=cfg(ossl111)");
3+
4+
#[allow(clippy::unusual_byte_groupings)]
5+
let ossl_vers = [
6+
(0x1_00_01_00_0, "ossl101"),
7+
(0x1_00_02_00_0, "ossl102"),
8+
(0x1_01_00_00_0, "ossl110"),
9+
(0x1_01_00_07_0, "ossl110g"),
10+
(0x1_01_00_08_0, "ossl110h"),
11+
(0x1_01_01_00_0, "ossl111"),
12+
(0x1_01_01_04_0, "ossl111d"),
13+
(0x3_00_00_00_0, "ossl300"),
14+
(0x3_01_00_00_0, "ossl310"),
15+
(0x3_02_00_00_0, "ossl320"),
16+
(0x3_03_00_00_0, "ossl330"),
17+
];
18+
19+
for (_, cfg) in ossl_vers {
20+
println!("cargo::rustc-check-cfg=cfg({cfg})");
21+
}
22+
823
#[allow(clippy::unusual_byte_groupings)]
924
if let Ok(v) = std::env::var("DEP_OPENSSL_VERSION_NUMBER") {
1025
println!("cargo:rustc-env=OPENSSL_API_VERSION={v}");
1126
// cfg setup from openssl crate's build script
1227
let version = u64::from_str_radix(&v, 16).unwrap();
13-
if version >= 0x1_00_01_00_0 {
14-
println!("cargo:rustc-cfg=ossl101");
15-
}
16-
if version >= 0x1_00_02_00_0 {
17-
println!("cargo:rustc-cfg=ossl102");
18-
}
19-
if version >= 0x1_01_00_00_0 {
20-
println!("cargo:rustc-cfg=ossl110");
21-
}
22-
if version >= 0x1_01_00_07_0 {
23-
println!("cargo:rustc-cfg=ossl110g");
24-
}
25-
if version >= 0x1_01_01_00_0 {
26-
println!("cargo:rustc-cfg=ossl111");
28+
for (ver, cfg) in ossl_vers {
29+
if version >= ver {
30+
println!("cargo:rustc-cfg={cfg}");
31+
}
2732
}
2833
}
2934
if let Ok(v) = std::env::var("DEP_OPENSSL_CONF") {

stdlib/src/ssl.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,14 @@ mod _ssl {
700700
vm: &VirtualMachine,
701701
) -> PyResult<Vec<PyObjectRef>> {
702702
let binary_form = binary_form.unwrap_or(false);
703-
let certs = self
704-
.ctx()
705-
.cert_store()
706-
.all_certificates()
707-
.iter()
708-
.map(|cert| cert_to_py(vm, cert, binary_form))
703+
let ctx = self.ctx();
704+
#[cfg(ossl300)]
705+
let certs = ctx.cert_store().all_certificates();
706+
#[cfg(not(ossl300))]
707+
let certs = ctx.cert_store().objects().iter().filter_map(|x| x.x509());
708+
let certs = certs
709+
.into_iter()
710+
.map(|ref cert| cert_to_py(vm, cert, binary_form))
709711
.collect::<Result<Vec<_>, _>>()?;
710712
Ok(certs)
711713
}

0 commit comments

Comments
 (0)