forked from Rust-related/RustPython
Fix build with ossl1
This commit is contained in:
@@ -1,29 +1,34 @@
|
||||
fn main() {
|
||||
println!(r#"cargo::rustc-check-cfg=cfg(osslconf, values("OPENSSL_NO_COMP"))"#);
|
||||
println!("cargo::rustc-check-cfg=cfg(ossl101)");
|
||||
println!("cargo::rustc-check-cfg=cfg(ossl102)");
|
||||
println!("cargo::rustc-check-cfg=cfg(ossl110)");
|
||||
println!("cargo::rustc-check-cfg=cfg(ossl110g)");
|
||||
println!("cargo::rustc-check-cfg=cfg(ossl111)");
|
||||
|
||||
#[allow(clippy::unusual_byte_groupings)]
|
||||
let ossl_vers = [
|
||||
(0x1_00_01_00_0, "ossl101"),
|
||||
(0x1_00_02_00_0, "ossl102"),
|
||||
(0x1_01_00_00_0, "ossl110"),
|
||||
(0x1_01_00_07_0, "ossl110g"),
|
||||
(0x1_01_00_08_0, "ossl110h"),
|
||||
(0x1_01_01_00_0, "ossl111"),
|
||||
(0x1_01_01_04_0, "ossl111d"),
|
||||
(0x3_00_00_00_0, "ossl300"),
|
||||
(0x3_01_00_00_0, "ossl310"),
|
||||
(0x3_02_00_00_0, "ossl320"),
|
||||
(0x3_03_00_00_0, "ossl330"),
|
||||
];
|
||||
|
||||
for (_, cfg) in ossl_vers {
|
||||
println!("cargo::rustc-check-cfg=cfg({cfg})");
|
||||
}
|
||||
|
||||
#[allow(clippy::unusual_byte_groupings)]
|
||||
if let Ok(v) = std::env::var("DEP_OPENSSL_VERSION_NUMBER") {
|
||||
println!("cargo:rustc-env=OPENSSL_API_VERSION={v}");
|
||||
// cfg setup from openssl crate's build script
|
||||
let version = u64::from_str_radix(&v, 16).unwrap();
|
||||
if version >= 0x1_00_01_00_0 {
|
||||
println!("cargo:rustc-cfg=ossl101");
|
||||
}
|
||||
if version >= 0x1_00_02_00_0 {
|
||||
println!("cargo:rustc-cfg=ossl102");
|
||||
}
|
||||
if version >= 0x1_01_00_00_0 {
|
||||
println!("cargo:rustc-cfg=ossl110");
|
||||
}
|
||||
if version >= 0x1_01_00_07_0 {
|
||||
println!("cargo:rustc-cfg=ossl110g");
|
||||
}
|
||||
if version >= 0x1_01_01_00_0 {
|
||||
println!("cargo:rustc-cfg=ossl111");
|
||||
for (ver, cfg) in ossl_vers {
|
||||
if version >= ver {
|
||||
println!("cargo:rustc-cfg={cfg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Ok(v) = std::env::var("DEP_OPENSSL_CONF") {
|
||||
|
||||
@@ -700,12 +700,14 @@ mod _ssl {
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult<Vec<PyObjectRef>> {
|
||||
let binary_form = binary_form.unwrap_or(false);
|
||||
let certs = self
|
||||
.ctx()
|
||||
.cert_store()
|
||||
.all_certificates()
|
||||
.iter()
|
||||
.map(|cert| cert_to_py(vm, cert, binary_form))
|
||||
let ctx = self.ctx();
|
||||
#[cfg(ossl300)]
|
||||
let certs = ctx.cert_store().all_certificates();
|
||||
#[cfg(not(ossl300))]
|
||||
let certs = ctx.cert_store().objects().iter().filter_map(|x| x.x509());
|
||||
let certs = certs
|
||||
.into_iter()
|
||||
.map(|ref cert| cert_to_py(vm, cert, binary_form))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(certs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user