Commit 17692dcc authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Attempt to support newer GNU TLS libraries. Need more work...

parent a2d62e9b
......@@ -4,6 +4,7 @@
# GNUTLS_FOUND - True if gnutls found.
# GNUTLS_INCLUDE_DIR - where to find gnutls.h, etc.
# GNUTLS_LIBRARIES - List of libraries when using gnutls.
# GNUTLS_NEW_VERSION - true if GnuTLS version is <= 2.10.0 (does not require additional separate gcrypt initialization)
if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARIES)
set(GNUTLS_FIND_QUIETLY TRUE)
......@@ -35,3 +36,14 @@ ENDIF(GNUTLS_FOUND)
# Lastly make it so that the GNUTLS_LIBRARY and GNUTLS_INCLUDE_DIR variables
# only show up under the advanced options in the gui cmake applications.
MARK_AS_ADVANCED( GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR )
# Now check if the library is recent. gnutls_hash was added in 2.10.0.
IF( NOT( "${GNUTLS_VERSION_TEST_FOR}" STREQUAL "${GNUTLS_LIBRARY}" ))
INCLUDE (CheckLibraryExists)
MESSAGE(STATUS "Rechecking GNUTLS_NEW_VERSION")
UNSET(GNUTLS_NEW_VERSION)
UNSET(GNUTLS_NEW_VERSION CACHE)
GET_FILENAME_COMPONENT(GNUTLS_PATH ${GNUTLS_LIBRARY} PATH)
CHECK_LIBRARY_EXISTS(gnutls gnutls_hash ${GNUTLS_PATH} GNUTLS_NEW_VERSION)
SET( GNUTLS_VERSION_TEST_FOR ${GNUTLS_LIBRARY} CACHE INTERNAL "Version the test was made against" )
ENDIF (NOT( "${GNUTLS_VERSION_TEST_FOR}" STREQUAL "${GNUTLS_LIBRARY}" ))
......@@ -50,6 +50,7 @@
#cmakedefine SKIP_DLCLOSE
#cmakedefine DIAMID_IDNA_IGNORE
#cmakedefine DIAMID_IDNA_REJECT
#cmakedefine GNUTLS_NEW_VERSION
#cmakedefine ERRORS_ON_TODO
#cmakedefine DEBUG
......
......@@ -183,14 +183,20 @@ int fd_core_initialize(void)
fd_log_threadname("Main");
/* Initialize gcrypt and gnutls */
#ifndef GNUTLS_NEW_VERSION
GNUTLS_TRACE( (void) gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread) );
GNUTLS_TRACE( (void) gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0) );
#endif /* GNUTLS_NEW_VERSION */
CHECK_GNUTLS_DO( gnutls_global_init(), return EINVAL );
if ( ! gnutls_check_version(GNUTLS_VERSION) ) {
fprintf(stderr, "The GNUTLS library is too old; found '%s', need '" GNUTLS_VERSION "'\n", gnutls_check_version(NULL));
return EINVAL;
} else {
#ifdef GNUTLS_NEW_VERSION
TRACE_DEBUG(INFO, "libgnutls '%s' initialized.", gnutls_check_version(NULL) );
#else /* GNUTLS_NEW_VERSION */
TRACE_DEBUG(INFO, "libgnutls '%s', libgcrypt '%s', initialized.", gnutls_check_version(NULL), gcry_check_version(NULL) );
#endif /* GNUTLS_NEW_VERSION */
}
/* Initialize the config with default values */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment