Skip to content

Commit

Permalink
Add support of openssl 1.1.1
Browse files Browse the repository at this point in the history
* See issue #758

Signed-off-by: Florentin Dubois <florentin.dubois@clever-cloud.com>
  • Loading branch information
FlorentinDUBOIS committed Jul 13, 2022
1 parent 1b3cd3c commit 9b14a65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions lib/build.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use std::env;

fn main() {
match env::var("DEP_OPENSSL_VERSION") {
Ok(ref v) if v == "101" => {
println!("cargo:rustc-cfg=ossl101");
match &env::var("DEP_OPENSSL_VERSION") {
Ok(v) if v == "101" || v == "102" => {
println!("cargo:rustc-cfg=ossl{}", v);
println!("cargo:rustc-cfg=ossl10x");
}
Ok(ref v) if v == "102" => {
println!("cargo:rustc-cfg=ossl102");
println!("cargo:rustc-cfg=ossl10x");
}
Ok(ref v) if v == "110" => {
println!("cargo:rustc-cfg=ossl110");
Ok(v) if v == "110" || v == "111" => {
println!("cargo:rustc-cfg=ossl{}", v);
println!("cargo:rustc-cfg=ossl11x");
}
_ => {
println!("cargo:rustc-cfg=ossl110");
println!("cargo:rustc-cfg=ossl111");
println!("cargo:rustc-cfg=ossl11x");
} //panic!("Unable to detect OpenSSL version"),
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/https_openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2381,15 +2381,15 @@ fn setup_curves(ctx: &mut SslContextBuilder) -> Result<(), ErrorStack> {
ctx.set_ecdh_auto(true)
}

#[cfg(ossl110)]
#[cfg(ossl11x)]
fn setup_curves(ctx: &mut SslContextBuilder) -> Result<(), ErrorStack> {
use openssl::ec::EcKey;

let curve = EcKey::from_curve_name(nid::Nid::X9_62_PRIME256V1)?;
ctx.set_tmp_ecdh(&curve)
}

#[cfg(all(not(ossl101), not(ossl102), not(ossl110)))]
#[cfg(all(not(ossl101), not(ossl102), not(ossl11x)))]
fn setup_curves(_: &mut SslContextBuilder) -> Result<(), ErrorStack> {
compile_error!("unsupported openssl version, please open an issue");
Ok(())
Expand Down

0 comments on commit 9b14a65

Please sign in to comment.