Skip to content

Commit

Permalink
Fix compilation when openssl deprecated APIs are not available.
Browse files Browse the repository at this point in the history
Closes #1094. Thanks to Rosen Penev.
  • Loading branch information
ralight committed Feb 8, 2019
1 parent 70c4097 commit be9c107
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

Build:
- Fix comparison of boolean values in CMake build. Closes #1101.
- Fix compilation when openssl deprecated APIs are not available.
Closes #1094.


1.5.5 - 20181211
Expand Down
20 changes: 12 additions & 8 deletions lib/net_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ int net__init(void)
#endif

#ifdef WITH_TLS
# if OPENSSL_VERSION_NUMBER < 0x10100000L || OPENSSL_API_COMPAT < 0x10100000L
SSL_load_error_strings();
SSL_library_init();
OpenSSL_add_all_algorithms();
# endif
if(tls_ex_index_mosq == -1){
tls_ex_index_mosq = SSL_get_ex_new_index(0, "client context", NULL, NULL, NULL);
}
Expand All @@ -100,16 +102,18 @@ int net__init(void)
void net__cleanup(void)
{
#ifdef WITH_TLS
#if OPENSSL_VERSION_NUMBER < 0x10100000L
ERR_remove_state(0);
#endif
#ifndef OPENSSL_NO_ENGINE
ENGINE_cleanup();
#endif
CONF_modules_unload(1);
# if OPENSSL_VERSION_NUMBER < 0x10100000L || OPENSSL_API_COMPAT < 0x10100000L
CRYPTO_cleanup_all_ex_data();
ERR_free_strings();
ERR_remove_state(0);
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();

# if !defined(OPENSSL_NO_ENGINE)
ENGINE_cleanup();
# endif
# endif

CONF_modules_unload(1);
#endif

#ifdef WITH_SRV
Expand Down
3 changes: 3 additions & 0 deletions lib/util_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ and the Eclipse Distribution License is available at
# include <sys/stat.h>
#endif

#ifdef WITH_TLS
# include <openssl/bn.h>
#endif

#ifdef WITH_BROKER
#include "mosquitto_broker_internal.h"
Expand Down
2 changes: 2 additions & 0 deletions src/mosquitto_passwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ int main(int argc, char *argv[])
signal(SIGINT, handle_sigint);
signal(SIGTERM, handle_sigint);

#if OPENSSL_VERSION_NUMBER < 0x10100000L || OPENSSL_API_COMPAT < 0x10100000L
OpenSSL_add_all_digests();
#endif

if(argc == 1){
print_usage();
Expand Down

0 comments on commit be9c107

Please sign in to comment.