Skip to content

Commit 3cfcf13

Browse files
committed
Merge branch 'master' of github.com:sfackler/rust-openssl
2 parents 791f2c8 + fde5b42 commit 3cfcf13

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ installation via an environment variable:
7373
set OPENSSL_DIR=C:\OpenSSL-Win64
7474
```
7575

76+
Note that this OpenSSL distribution does not ship with any root certificates.
77+
So to make requests to servers on the internet, you have to install them
78+
manually. Download the [cacert.pem file from here], copy it somewhere safe
79+
(`C:\OpenSSL-Win64\certs` is a good place) and point the `SSL_CERT_FILE`
80+
environment variable there:
81+
82+
```
83+
set SSL_CERT_FILE=C:\OpenSSL-Win64\certs\cacert.pem
84+
```
85+
86+
[cacert.pem file from here]: https://curl.haxx.se/docs/caextract.html
87+
7688
After that, you're just a `cargo build` away!
7789

7890
### Windows GNU (MinGW)
@@ -102,6 +114,12 @@ The build script can be configured via environment variables:
102114
* `OPENSSL_DIR` - If specified, a directory that will be used to find
103115
OpenSSL installation. It's expected that under this directory the `include`
104116
folder has header files and a `lib` folder has the runtime libraries.
117+
* `OPENSSL_LIB_DIR` - If specified, a directory that will be used to find
118+
OpenSSL libraries. Overrides the `lib` folder implied by `OPENSSL_DIR`
119+
(if specified).
120+
* `OPENSSL_INCLUDE_DIR` - If specified, a directory that will be used to find
121+
OpenSSL header files. Overrides the `include` folder implied by `OPENSSL_DIR`
122+
(if specified).
105123
* `OPENSSL_STATIC` - If specified, OpenSSL libraries will be statically rather
106124
than dynamically linked.
107125

openssl-sys/build.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@ use std::process::Command;
1111
fn main() {
1212
let target = env::var("TARGET").unwrap();
1313

14-
let openssl_dir = env::var_os("OPENSSL_DIR").unwrap_or_else(|| {
15-
find_openssl_dir(&target)
16-
});
14+
let lib_dir = env::var_os("OPENSSL_LIB_DIR").map(PathBuf::from);
15+
let include_dir = env::var_os("OPENSSL_INCLUDE_DIR").map(PathBuf::from);
16+
17+
let (lib_dir, include_dir) = if lib_dir.is_none() || include_dir.is_none() {
18+
let openssl_dir = env::var_os("OPENSSL_DIR").unwrap_or_else(|| {
19+
find_openssl_dir(&target)
20+
});
21+
let openssl_dir = Path::new(&openssl_dir);
22+
let lib_dir = lib_dir.unwrap_or_else(|| openssl_dir.join("lib"));
23+
let include_dir = include_dir.unwrap_or_else(|| openssl_dir.join("include"));
24+
(lib_dir, include_dir)
25+
} else {
26+
(lib_dir.unwrap(), include_dir.unwrap())
27+
};
1728

18-
let lib_dir = Path::new(&openssl_dir).join("lib");
19-
let include_dir = Path::new(&openssl_dir).join("include");
2029
if !Path::new(&lib_dir).exists() {
2130
panic!("OpenSSL library directory does not exist: {}",
2231
lib_dir.to_string_lossy());
2332
}
24-
2533
if !Path::new(&include_dir).exists() {
2634
panic!("OpenSSL include directory does not exist: {}",
2735
include_dir.to_string_lossy());

0 commit comments

Comments
 (0)