Correctly initialize OpenSSL

This commit is contained in:
Matthias Schiffer 2013-11-27 19:19:38 +01:00
parent c62a0f592c
commit 2f516f9cea
3 changed files with 20 additions and 1 deletions

View file

@ -40,7 +40,7 @@ add_executable(fastd
set_property(TARGET fastd PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}") 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 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}) 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) add_dependencies(fastd version)

View file

@ -44,6 +44,12 @@
#include <sodium/core.h> #include <sodium/core.h>
#endif #endif
#ifdef USE_OPENSSL
#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#endif
static volatile bool sighup = false; static volatile bool sighup = false;
static volatile bool terminate = false; static volatile bool terminate = false;
@ -744,6 +750,12 @@ int main(int argc, char *argv[]) {
sodium_init(); sodium_init();
#endif #endif
#ifdef USE_OPENSSL
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
OPENSSL_config(NULL);
#endif
fastd_context_t ctx = {}; fastd_context_t ctx = {};
close_fds(&ctx); close_fds(&ctx);
@ -878,5 +890,11 @@ int main(int argc, char *argv[]) {
close_log(&ctx); close_log(&ctx);
fastd_config_release(&ctx, &conf); fastd_config_release(&ctx, &conf);
#ifdef USE_OPENSSL
CONF_modules_free();
EVP_cleanup();
ERR_free_strings();
#endif
return 0; return 0;
} }

View file

@ -46,6 +46,7 @@
#cmakedefine HAVE_LIBSODIUM #cmakedefine HAVE_LIBSODIUM
#cmakedefine USE_OPENSSL
#define MAX_CONFIG_DEPTH @MAX_CONFIG_DEPTH_NUM@ #define MAX_CONFIG_DEPTH @MAX_CONFIG_DEPTH_NUM@