--- configure.orig	2017-09-12 13:21:59 UTC
+++ configure
@@ -12661,7 +12649,7 @@ CC=$lt_save_CC
 
 
 
-if test "z$RM" == "z" ; then
+if test "z$RM" = "z" ; then
     # Extract the first word of "rm", so it can be a program name with args.
 set dummy rm; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -13648,7 +13636,7 @@ case "${host}" in
         ;;
 esac
 
-if test "z$shrext" == "z" ; then
+if test "z$shrext" = "z" ; then
     shrext=$shrext_cmds
 fi
 
@@ -14384,6 +14372,7 @@ elif test "z$with_openssl" != "z" ; then
 	*-*-osf5*) openssl_exlibs=;;
 	*-*-openbsd*) openssl_exlibs=;;
 	*-*-netbsd*) openssl_exlibs=;;
+	*-*-freebsd*) openssl_exlibs=;;
 	#FIXME: check if lib "dl" is required
 	*)          openssl_exlibs=-ldl;;
     esac
@@ -14641,9 +14630,9 @@ if test "z$OPENSSL_FOUND" = "zno" ; then
     for dir in $ac_openssl_lib_dir ; do
 	if test -f $dir/libcrypto.a ; then
 	    	    if test "z$dir" = "z/usr/lib" ; then
-		OPENSSL_LIBS="-lcrypto -ldl"
+		OPENSSL_LIBS="-lcrypto"
 	    else
-		OPENSSL_LIBS="-L$dir -lcrypto -ldl"
+		OPENSSL_LIBS="-L$dir -lcrypto "
 	    fi
 	    OPENSSL_LIBS_FOUND="yes"
 	    ac_found_openssl_lib_dir=$dir
@@ -14668,7 +14669,7 @@ $as_echo_n "checking for openssl librari
 /* end confdefs.h.  */

             #include <openssl/opensslv.h>
-        #if OPENSSL_VERSION_NUMBER == 0x20000000L && defined(LIBRESSL_VERSION_NUMBER)
+        #if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L
         yes
         #endif

@@ -14676,7 +14665,7 @@ _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   $EGREP "yes" >/dev/null 2>&1; then :
 
-        OPENSSL_VERSION="1.0.0 (libressl)"
+        OPENSSL_VERSION="1.0.0 (LibreSSL < 2.7)"
 
 else
 
@@ -14692,7 +14681,31 @@ rm -f conftest*
 /* end confdefs.h.  */
 
             #include <openssl/opensslv.h>
-        #if OPENSSL_VERSION_NUMBER >= 0x10100000L
+        #if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L
+        yes
+        #endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+
+        OPENSSL_VERSION="1.1.0 (LibreSSL >= 2.7)"
+
+else
+
+        OPENSSL_VERSION=""
+
+fi
+rm -f conftest*
+
+    fi
+
+    if test "z$OPENSSL_VERSION" = "z" ; then
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+            #include <openssl/opensslv.h>
+        #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
         yes
         #endif
 
@@ -14749,12 +14762,12 @@ fi
 if test "z$OPENSSL_FOUND" = "zyes" ; then
     XMLSEC_NO_OPENSSL="0"
     OPENSSL_CFLAGS="$OPENSSL_CFLAGS -DXMLSEC_CRYPTO_OPENSSL=1"
-    XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST openssl"
+    XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST openssl"; CPPFLAGS="$CPPFLAGS $OPENSSL_CFLAGS"
 else
     XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST openssl"
 fi
 
- if test "z$XMLSEC_NO_OPENSSL" == "z1"; then
+ if test "z$XMLSEC_NO_OPENSSL" = "z1"; then
   XMLSEC_NO_OPENSSL_TRUE=
   XMLSEC_NO_OPENSSL_FALSE='#'
 else
@@ -14776,7 +14789,7 @@ NSPR_MIN_VERSION="4.4.1"
 NSS_CFLAGS=""
 NSS_LIBS=""
 NSS_LIBS_LIST="-lnss3 -lsmime3"
-NSPR_LIBS_LIST="-lnspr4 -lplds4 -lplc4"
+NSPR_LIBS_LIST="-lnspr4 -lplds4 -lplc4 -lpthread"
 NSS_CRYPTO_LIB="$XMLSEC_PACKAGE-nss"
 NSS_FOUND="no"
 NSPR_PACKAGE=mozilla-nspr
@@ -15211,15 +15224,15 @@ $as_echo_n "checking for nss libraries >
     NSS_NSS_H=""
 
     if test "z$with_nss" != "z" ; then
-	NSS_CFLAGS="$NSS_CFLAGS -I$with_nss/include -I$with_nss/include/nss"
+	NSS_CFLAGS="$NSS_CFLAGS -I$with_nss/include/nss/nss -I$with_nss/include/nss"
 	if test "z$with_gnu_ld" = "zyes" ; then
-	    NSS_LIBS="$NSS_LIBS -Wl,-rpath-link -Wl,$with_nss/lib -L$with_nss/lib $NSS_LIBS_LIST"
+	    NSS_LIBS="$NSS_LIBS -Wl,-rpath-link -Wl,$with_nss/lib/nss -L$with_nss/lib/nss $NSS_LIBS_LIST"
         else
-	    NSS_LIBS="$NSS_LIBS -L$with_nss/lib $NSS_LIBS_LIST"
+	    NSS_LIBS="$NSS_LIBS -L$with_nss/lib/nss $NSS_LIBS_LIST"
         fi
 	NSS_INCLUDES_FOUND="yes"
 	NSS_LIBS_FOUND="yes"
-	NSS_NSS_H="$with_nss/include/nss.h"
+	NSS_NSS_H="$with_nss/include/nss/nss/nss.h"
     else
 	for dir in $ac_nss_inc_dir ; do
 	    if test -f $dir/nss/nss.h ; then
