Skip to content

Commit daaca3f

Browse files
authored
Merge pull request #2122 from DanielSidhion/propagate-openssl-dir-vendored
Configure OpenSSL data dir on vendored builds.
2 parents a7c7bf0 + 734d2c5 commit daaca3f

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

openssl-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bssl-sys = { version = "0.1.0", optional = true }
2525
[build-dependencies]
2626
bindgen = { version = "0.65.0", optional = true, features = ["experimental"] }
2727
cc = "1.0.61"
28-
openssl-src = { version = "300.1.2", optional = true, features = ["legacy"] }
28+
openssl-src = { version = "300.2.0", optional = true, features = ["legacy"] }
2929
pkg-config = "0.3.9"
3030
vcpkg = "0.2.8"
3131

openssl-sys/build/find_vendored.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
use openssl_src;
22
use std::path::PathBuf;
33

4+
use super::env;
5+
46
pub fn get_openssl(_target: &str) -> (Vec<PathBuf>, PathBuf) {
5-
let artifacts = openssl_src::Build::new().build();
7+
let openssl_config_dir = env("OPENSSL_CONFIG_DIR");
8+
9+
let mut openssl_src_build = openssl_src::Build::new();
10+
if let Some(value) = openssl_config_dir {
11+
openssl_src_build.openssl_dir(PathBuf::from(value));
12+
}
13+
14+
let artifacts = openssl_src_build.build();
615
println!("cargo:vendored=1");
716
println!(
817
"cargo:root={}",

openssl/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
//! openssl = { version = "0.10", features = ["vendored"] }
2020
//! ```
2121
//!
22-
//! The vendored copy will not be configured to automatically find the system's root certificates, but the
23-
//! `openssl-probe` crate can be used to do that instead.
22+
//! The vendored copy will be configured to automatically find a configuration and root certificates at `/usr/local/ssl`.
23+
//! This path can be overridden with an environment variable (see the manual section below).
24+
//! Alternatively, the `openssl-probe` crate can be used to find root certificates at runtime.
2425
//!
2526
//! ## Automatic
2627
//!
@@ -67,6 +68,12 @@
6768
//! if nonstandard library names were used for whatever reason.
6869
//! * `OPENSSL_NO_VENDOR` - If set, always find OpenSSL in the system, even if the `vendored` feature is enabled.
6970
//!
71+
//! If the `vendored` Cargo feature is enabled, the following environment variable can also be used to further configure
72+
//! the OpenSSL build.
73+
//!
74+
//! * `OPENSSL_CONFIG_DIR` - If set, the copy of OpenSSL built by the `openssl-src` crate will be configured to look for
75+
//! configuration files and root certificates in this directory.
76+
//!
7077
//! Additionally, these variables can be prefixed with the upper-cased target architecture (e.g.
7178
//! `X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR`), which can be useful when cross compiling.
7279
//!

0 commit comments

Comments
 (0)