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") {
|
if target.contains("win32") || target.contains("win64") || target.contains("windows") {
|
||||||
println!("cargo:rustc-flags=-l crypto -l ssl -l gdi32 -l wsock32");
|
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(vec![]);
|
||||||
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);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let err = match pkg_config::find_library("openssl") {
|
let err = match pkg_config::find_library("openssl") {
|
||||||
Ok(info) => {
|
Ok(info) => {
|
||||||
build_old_openssl_shim(true, info.include_paths);
|
build_old_openssl_shim(info.include_paths);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Err(err) => err,
|
Err(err) => err,
|
||||||
|
|
@ -40,23 +34,19 @@ fn main() {
|
||||||
// pkg-config doesn't know of OpenSSL on FreeBSD 10.1 and OpenBSD uses LibreSSL
|
// pkg-config doesn't know of OpenSSL on FreeBSD 10.1 and OpenBSD uses LibreSSL
|
||||||
if target.contains("bsd") {
|
if target.contains("bsd") {
|
||||||
println!("cargo:rustc-flags=-l crypto -l ssl");
|
println!("cargo:rustc-flags=-l crypto -l ssl");
|
||||||
// going to assume the base system includes a new version of openssl
|
build_old_openssl_shim(vec![]);
|
||||||
build_old_openssl_shim(false, vec![]);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
panic!("unable to find openssl: {}", err);
|
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();
|
let mut config = gcc::Config::new();
|
||||||
|
|
||||||
for path in include_paths {
|
for path in include_paths {
|
||||||
config.include(path);
|
config.include(path);
|
||||||
}
|
}
|
||||||
if is_old {
|
|
||||||
config.define("OLD_OPENSSL", None);
|
|
||||||
}
|
|
||||||
|
|
||||||
config.file("src/old_openssl_shim.c")
|
config.file("src/old_openssl_shim.c")
|
||||||
.compile("libold_openssl_shim.a");
|
.compile("libold_openssl_shim.a");
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <openssl/hmac.h>
|
#include <openssl/hmac.h>
|
||||||
|
|
||||||
#ifdef OLD_OPENSSL
|
#if OPENSSL_VERSION_NUMBER < 0x1000000L
|
||||||
// Copied from openssl crypto/hmac/hmac.c
|
// Copied from openssl crypto/hmac/hmac.c
|
||||||
int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
|
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;
|
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) {
|
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);
|
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) {
|
int HMAC_Final_shim(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) {
|
||||||
return HMAC_Final(ctx, md, len);
|
return HMAC_Final(ctx, md, len);
|
||||||
}
|
}
|
||||||
#endif /* OLD_OPENSSL */
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue