Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #3139 from mind04/openssl
Browse files Browse the repository at this point in the history
improve openssl m4 file and some cleanup
  • Loading branch information
Habbie committed Dec 30, 2015
2 parents 6408f66 + 793f83f commit 85aa638
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
17 changes: 8 additions & 9 deletions m4/ax_check_openssl.m4
Expand Up @@ -32,7 +32,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 8
#serial 8 (PowerDNS modified)

AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL])
AC_DEFUN([AX_CHECK_OPENSSL], [
Expand All @@ -53,10 +53,10 @@ AC_DEFUN([AX_CHECK_OPENSSL], [
# then use that information and don't search ssldirs
AC_PATH_PROG([PKG_CONFIG], [pkg-config])
if test x"$PKG_CONFIG" != x""; then
OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
OPENSSL_LDFLAGS=`$PKG_CONFIG libcryptol --libs-only-L 2>/dev/null`
if test $? = 0; then
OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
OPENSSL_LIBS=`$PKG_CONFIG libcrypto --libs-only-l 2>/dev/null`
OPENSSL_INCLUDES=`$PKG_CONFIG libcrypto --cflags-only-I 2>/dev/null`
found=true
fi
fi
Expand All @@ -75,11 +75,11 @@ AC_DEFUN([AX_CHECK_OPENSSL], [
if ! $found; then
OPENSSL_INCLUDES=
for ssldir in $ssldirs; do
AC_MSG_CHECKING([for openssl/ssl.h in $ssldir])
if test -f "$ssldir/include/openssl/ssl.h"; then
AC_MSG_CHECKING([for openssl/crypto.h in $ssldir])
if test -f "$ssldir/include/openssl/crypto.h"; then
OPENSSL_INCLUDES="-I$ssldir/include"
OPENSSL_LDFLAGS="-L$ssldir/lib"
OPENSSL_LIBS="-lssl -lcrypto"
OPENSSL_LIBS="-lcrypto"
found=true
AC_MSG_RESULT([yes])
break
Expand All @@ -106,7 +106,7 @@ AC_DEFUN([AX_CHECK_OPENSSL], [
LIBS="$OPENSSL_LIBS $LIBS"
CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)])],
[AC_LANG_PROGRAM([#include <openssl/crypto.h>], [CRYPTO_free(NULL)])],
[
AC_MSG_RESULT([yes])
$1
Expand All @@ -122,4 +122,3 @@ AC_DEFUN([AX_CHECK_OPENSSL], [
AC_SUBST([OPENSSL_LIBS])
AC_SUBST([OPENSSL_LDFLAGS])
])

4 changes: 3 additions & 1 deletion pdns/Makefile.am
Expand Up @@ -226,6 +226,7 @@ endif

if OPENSSL
pdns_server_SOURCES += opensslsigners.cc opensslsigners.hh
pdns_server_LDFLAGS += $(OPENSSL_LDFLAGS)
pdns_server_LDADD += $(OPENSSL_LIBS)
endif

Expand Down Expand Up @@ -325,7 +326,8 @@ pdnsutil_LDADD += $(LIBSODIUM_LIBS)
endif

if OPENSSL
pdnsutil_SOURCES += opensslsigners.cc
pdnsutil_SOURCES += opensslsigners.cc opensslsigners.hh
pdnsutil_LDFLAGS += $(OPENSSL_LDFLAGS)
pdnsutil_LDADD += $(OPENSSL_LIBS)
endif

Expand Down
11 changes: 7 additions & 4 deletions pdns/opensslsigners.hh
Expand Up @@ -5,7 +5,7 @@

#include "dns_random.hh"

/* pthread OpemSSL locking */
/* pthread locking */

static pthread_mutex_t *locks;

Expand Down Expand Up @@ -43,16 +43,19 @@ void openssl_thread_cleanup()
OPENSSL_free(locks);
}


/* seeding PRNG */

void openssl_seed()
{
{
std::string entropy;
entropy.reserve(1024);

unsigned int r;
for(int i=0; i<1024; i+=4) {
r=dns_random(0xffffffff);
entropy.append((const char*)&r, 4);
}

RAND_seed((const unsigned char*)entropy.c_str(), 1024);
}
3 changes: 3 additions & 0 deletions pdns/version.cc
Expand Up @@ -99,6 +99,9 @@ void showBuildConfiguration()
#ifdef HAVE_LIBSODIUM
"sodium " <<
#endif
#ifdef HAVE_OPENSSL
"openssl " <<
#endif
#ifdef HAVE_LIBDL
"libdl " <<
#endif
Expand Down

0 comments on commit 85aa638

Please sign in to comment.