Commit d681d745 authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Renamed GNUTLS_NEW_VERSION and added GNUTLS_VERSION_300 to prepare for API change in gnutls

parent 90fd8010
......@@ -4,7 +4,8 @@
# 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)
# GNUTLS_VERSION_210 - true if GnuTLS version is >= 2.10.0 (does not require additional separate gcrypt initialization)
# GNUTLS_VERSION_300 - true if GnuTLS version is >= 3.00.0 (x509 verification functions changed)
if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARIES)
set(GNUTLS_FIND_QUIETLY TRUE)
......@@ -38,12 +39,16 @@ ENDIF(GNUTLS_FOUND)
MARK_AS_ADVANCED( GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR )
# Now check if the library is recent. gnutls_hash was added in 2.10.0.
# Also test library is even more recent. gnutls_x509_trust_list_verify_crt was added in 3.00.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)
MESSAGE(STATUS "Rechecking GNUTLS_VERSION_210 and GNUTLS_VERSION_300")
UNSET(GNUTLS_VERSION_210)
UNSET(GNUTLS_VERSION_210 CACHE)
UNSET(GNUTLS_VERSION_300)
UNSET(GNUTLS_VERSION_300 CACHE)
GET_FILENAME_COMPONENT(GNUTLS_PATH ${GNUTLS_LIBRARY} PATH)
CHECK_LIBRARY_EXISTS(gnutls gnutls_hash ${GNUTLS_PATH} GNUTLS_NEW_VERSION)
CHECK_LIBRARY_EXISTS(gnutls gnutls_hash ${GNUTLS_PATH} GNUTLS_VERSION_210)
CHECK_LIBRARY_EXISTS(gnutls gnutls_x509_trust_list_verify_crt ${GNUTLS_PATH} GNUTLS_VERSION_300)
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,7 +50,8 @@
#cmakedefine SKIP_DLCLOSE
#cmakedefine DIAMID_IDNA_IGNORE
#cmakedefine DIAMID_IDNA_REJECT
#cmakedefine GNUTLS_NEW_VERSION
#cmakedefine GNUTLS_VERSION_210
#cmakedefine GNUTLS_VERSION_300
#cmakedefine ERRORS_ON_TODO
#cmakedefine DEBUG
......
......@@ -183,20 +183,20 @@ int fd_core_initialize(void)
fd_log_threadname("Main");
/* Initialize gcrypt and gnutls */
#ifndef GNUTLS_NEW_VERSION
#ifndef GNUTLS_VERSION_210
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 */
#endif /* GNUTLS_VERSION_210 */
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
#ifdef GNUTLS_VERSION_210
TRACE_DEBUG(INFO, "libgnutls '%s' initialized.", gnutls_check_version(NULL) );
#else /* GNUTLS_NEW_VERSION */
#else /* GNUTLS_VERSION_210 */
TRACE_DEBUG(INFO, "libgnutls '%s', libgcrypt '%s', initialized.", gnutls_check_version(NULL), gcry_check_version(NULL) );
#endif /* GNUTLS_NEW_VERSION */
#endif /* GNUTLS_VERSION_210 */
}
/* 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