Ask openssl what version it is
This commit is contained in:
parent
9cb3b44e9a
commit
15ff737b8c
|
|
@ -19,19 +19,13 @@ fn main() {
|
|||
|
||||
if target.contains("win32") || target.contains("win64") || target.contains("windows") {
|
||||
println!("cargo:rustc-flags=-l crypto -l ssl -l gdi32 -l wsock32");
|
||||
// going to assume the user has a new version of openssl
|
||||
build_old_openssl_shim(false, vec![]);
|
||||
return;
|
||||
}
|
||||
|
||||
if let Ok(info) = pkg_config::Config::new().atleast_version("1.0.0").find("openssl") {
|
||||
build_old_openssl_shim(false, info.include_paths);
|
||||
build_old_openssl_shim(vec![]);
|
||||
return;
|
||||
}
|
||||
|
||||
let err = match pkg_config::find_library("openssl") {
|
||||
Ok(info) => {
|
||||
build_old_openssl_shim(true, info.include_paths);
|
||||
build_old_openssl_shim(info.include_paths);
|
||||
return;
|
||||
}
|
||||
Err(err) => err,
|
||||
|
|
@ -40,23 +34,19 @@ fn main() {
|
|||
// pkg-config doesn't know of OpenSSL on FreeBSD 10.1 and OpenBSD uses LibreSSL
|
||||
if target.contains("bsd") {
|
||||
println!("cargo:rustc-flags=-l crypto -l ssl");
|
||||
// going to assume the base system includes a new version of openssl
|
||||
build_old_openssl_shim(false, vec![]);
|
||||
build_old_openssl_shim(vec![]);
|
||||
return;
|
||||
}
|
||||
|
||||
panic!("unable to find openssl: {}", err);
|
||||
}
|
||||
|
||||
fn build_old_openssl_shim(is_old: bool, include_paths: Vec<Path>) {
|
||||
fn build_old_openssl_shim(include_paths: Vec<Path>) {
|
||||
let mut config = gcc::Config::new();
|
||||
|
||||
for path in include_paths {
|
||||
config.include(path);
|
||||
}
|
||||
if is_old {
|
||||
config.define("OLD_OPENSSL", None);
|
||||
}
|
||||
|
||||
config.file("src/old_openssl_shim.c")
|
||||
.compile("libold_openssl_shim.a");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <openssl/hmac.h>
|
||||
|
||||
#ifdef OLD_OPENSSL
|
||||
#if OPENSSL_VERSION_NUMBER < 0x1000000L
|
||||
// Copied from openssl crypto/hmac/hmac.c
|
||||
int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
|
||||
{
|
||||
|
|
@ -33,7 +33,7 @@ int HMAC_Final_shim(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#else /* OLD_OPENSSL */
|
||||
#else
|
||||
|
||||
int HMAC_Init_ex_shim(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md, ENGINE *impl) {
|
||||
return HMAC_Init_ex(ctx, key, key_len, md, impl);
|
||||
|
|
@ -46,4 +46,4 @@ int HMAC_Update_shim(HMAC_CTX *ctx, const unsigned char *data, int len) {
|
|||
int HMAC_Final_shim(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) {
|
||||
return HMAC_Final(ctx, md, len);
|
||||
}
|
||||
#endif /* OLD_OPENSSL */
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue