From 2f516f9ceaaf5b964de953aae82498818db9091b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 27 Nov 2013 19:19:38 +0100 Subject: Correctly initialize OpenSSL --- src/CMakeLists.txt | 2 +- src/fastd.c | 18 ++++++++++++++++++ src/fastd_config.h.in | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da20721..4bcbb65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,7 +40,7 @@ add_executable(fastd set_property(TARGET fastd PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}") set_property(TARGET fastd PROPERTY LINK_FLAGS "-pthread ${UECC_LDFLAGS_OTHER} ${NACL_LDFLAGS_OTHER} ${OPENSSL_CRYPTO_LDFLAGS_OTHER}") set_property(TARGET fastd APPEND PROPERTY INCLUDE_DIRECTORIES ${CAP_INCLUDE_DIR} ${NACL_INCLUDE_DIRS}) -target_link_libraries(fastd protocols methods ciphers macs ${RT_LIBRARY} ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARIES}) +target_link_libraries(fastd protocols methods ciphers macs ${RT_LIBRARY} ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES}) add_dependencies(fastd version) diff --git a/src/fastd.c b/src/fastd.c index 469fc6f..28ff207 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -44,6 +44,12 @@ #include #endif +#ifdef USE_OPENSSL +#include +#include +#include +#endif + static volatile bool sighup = false; static volatile bool terminate = false; @@ -744,6 +750,12 @@ int main(int argc, char *argv[]) { sodium_init(); #endif +#ifdef USE_OPENSSL + ERR_load_crypto_strings(); + OpenSSL_add_all_algorithms(); + OPENSSL_config(NULL); +#endif + fastd_context_t ctx = {}; close_fds(&ctx); @@ -878,5 +890,11 @@ int main(int argc, char *argv[]) { close_log(&ctx); fastd_config_release(&ctx, &conf); +#ifdef USE_OPENSSL + CONF_modules_free(); + EVP_cleanup(); + ERR_free_strings(); +#endif + return 0; } diff --git a/src/fastd_config.h.in b/src/fastd_config.h.in index 8ef3aa0..8a6ae22 100644 --- a/src/fastd_config.h.in +++ b/src/fastd_config.h.in @@ -46,6 +46,7 @@ #cmakedefine HAVE_LIBSODIUM +#cmakedefine USE_OPENSSL #define MAX_CONFIG_DEPTH @MAX_CONFIG_DEPTH_NUM@ -- cgit v1.2.3