From 03f6c2f0160de7646d00297da70074f93fda82e3 Mon Sep 17 00:00:00 2001 From: dmiller Date: Sat, 11 Nov 2017 17:43:24 +0000 Subject: [PATCH] Backport fix from libssh2/libssh2#176 for openssl 1.1 compatibility --- libssh2/src/openssl.c | 4 ++++ libssh2/src/openssl.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/libssh2/src/openssl.c b/libssh2/src/openssl.c index 4f63ef92b..411f9f69c 100644 --- a/libssh2/src/openssl.c +++ b/libssh2/src/openssl.c @@ -1062,6 +1062,7 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session, "Unable to extract public key from private key " "file: Unable to open private key file"); } +#if OPENSSL_VERSION_NUMBER < 0x10100000L if (!EVP_get_cipherbyname("des")) { /* If this cipher isn't loaded it's a pretty good indication that none * are. I have *NO DOUBT* that there's a better way to deal with this @@ -1070,6 +1071,7 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session, */ OpenSSL_add_all_ciphers(); } +#endif BIO_reset(bp); pk = PEM_read_bio_PrivateKey(bp, NULL, NULL, (void*)passphrase); BIO_free(bp); @@ -1138,6 +1140,7 @@ _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session, if (!bp) { return -1; } +#if OPENSSL_VERSION_NUMBER < 0x10100000L if (!EVP_get_cipherbyname("des")) { /* If this cipher isn't loaded it's a pretty good indication that none * are. I have *NO DOUBT* that there's a better way to deal with this @@ -1146,6 +1149,7 @@ _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session, */ OpenSSL_add_all_ciphers(); } +#endif BIO_reset(bp); pk = PEM_read_bio_PrivateKey(bp, NULL, NULL, (void*)passphrase); BIO_free(bp); diff --git a/libssh2/src/openssl.h b/libssh2/src/openssl.h index 3ca71fa8a..7b38cc12a 100644 --- a/libssh2/src/openssl.h +++ b/libssh2/src/openssl.h @@ -226,10 +226,16 @@ int _libssh2_md5_init(libssh2_md5_ctx *ctx); #define libssh2_hmac_cleanup(ctx) HMAC_cleanup(ctx) #endif +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#define libssh2_crypto_init() \ + ENGINE_load_builtin_engines(); \ + ENGINE_register_all_complete() +#else #define libssh2_crypto_init() \ OpenSSL_add_all_algorithms(); \ ENGINE_load_builtin_engines(); \ ENGINE_register_all_complete() +#endif #define libssh2_crypto_exit()