From d22ada23c2828cc111ce58370ddf802e988f83a3 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Mon, 10 May 2021 11:21:39 -0500 Subject: [PATCH] Improve the openssl vendoring situation --- .github/workflows/ci.yaml | 10 ++++++++-- Cargo.toml | 1 + vm/Cargo.toml | 5 +++-- vm/src/stdlib/ssl.rs | 6 +++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7fb327774..46adfc218 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,7 +29,10 @@ jobs: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 - name: Set up the Windows environment - run: choco install llvm + shell: bash + run: | + choco install llvm openssl + echo "OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" >>$GITHUB_ENV if: runner.os == 'Windows' - name: Set up the Mac environment run: brew install autoconf automake libtool @@ -60,7 +63,10 @@ jobs: with: python-version: 3.8 - name: Set up the Windows environment - run: choco install llvm + shell: bash + run: | + choco install llvm openssl + echo "OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" >>$GITHUB_ENV if: runner.os == 'Windows' - name: Set up the Mac environment run: brew install autoconf automake libtool diff --git a/Cargo.toml b/Cargo.toml index a6ca39e48..86ba88a9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ threading = ["rustpython-vm/threading"] zlib = ["rustpython-vm/zlib"] ssl = ["rustpython-vm/ssl"] +ssl-vendor = ["rustpython-vm/ssl-vendor"] [dependencies] log = "0.4" diff --git a/vm/Cargo.toml b/vm/Cargo.toml index d64344248..c44a45cde 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -22,7 +22,8 @@ ast = ["rustpython-ast"] compiler = ["rustpython-compiler", "rustpython-compiler-core", "ast"] parser = ["rustpython-parser", "ast"] -ssl = ["openssl", "openssl-sys", "openssl-probe", "foreign-types-shared"] +ssl = ["openssl", "openssl-sys", "foreign-types-shared"] +ssl-vendor = ["ssl", "openssl/vendored", "openssl-probe"] [dependencies] # Crypto: @@ -119,7 +120,7 @@ uname = "0.1.1" gethostname = "0.2.0" socket2 = "0.4.0" rustyline = "8.0" -openssl = { version = "0.10.32", features = ["vendored"], optional = true } +openssl = { version = "0.10.32", optional = true } openssl-sys = { version = "0.9", optional = true } openssl-probe = { version = "0.1", optional = true } which = "4.0" diff --git a/vm/src/stdlib/ssl.rs b/vm/src/stdlib/ssl.rs index cd1c0d486..6d54fefa2 100644 --- a/vm/src/stdlib/ssl.rs +++ b/vm/src/stdlib/ssl.rs @@ -967,9 +967,9 @@ 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(), + #[cfg(feature = "ssl-vendor")] + if let None | Some("0") = option_env!("OPENSSL_NO_VENDOR") { + openssl_probe::init_ssl_cert_env_vars(); } openssl::init();