From 984fcdc589ac9babcdf3c9c345e025f0112c494f Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Sun, 12 Apr 2020 23:18:05 -0500 Subject: [PATCH] Fix openssl certificates not being found when openssl is vendored --- Cargo.lock | 7 +++++++ vm/Cargo.toml | 1 + vm/src/stdlib/ssl.rs | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 6727733736..20fb3a0640 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1032,6 +1032,12 @@ dependencies = [ "openssl-sys", ] +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + [[package]] name = "openssl-src" version = "111.8.1+1.1.1f" @@ -1584,6 +1590,7 @@ dependencies = [ "num_enum", "once_cell", "openssl", + "openssl-probe", "openssl-sys", "paste", "pwd", diff --git a/vm/Cargo.toml b/vm/Cargo.toml index 4cf1a821a6..840302fa98 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -95,6 +95,7 @@ socket2 = { version = "0.3", features = ["unix"] } rustyline = "6.0" openssl = { version = "0.10", features = ["vendored"] } openssl-sys = "0.9" +openssl-probe = "0.1" [target.'cfg(not(any(target_arch = "wasm32", target_os = "redox")))'.dependencies] dns-lookup = "1.0" diff --git a/vm/src/stdlib/ssl.rs b/vm/src/stdlib/ssl.rs index 7fc8e30693..7cb133b93c 100644 --- a/vm/src/stdlib/ssl.rs +++ b/vm/src/stdlib/ssl.rs @@ -740,6 +740,11 @@ fn parse_version_info(mut n: i64) -> (u8, u8, u8, u8, u8) { } pub fn make_module(vm: &VirtualMachine) -> PyObjectRef { + // if openssl is vendored, it doesn't know the locations of system certificates + match option_env!("OPENSSL_NO_VENDOR") { + None | Some("0") => {} + _ => openssl_probe::init_ssl_cert_env_vars(), + } openssl::init(); let ctx = &vm.ctx; let ssl_error = create_type(