Browse Source

fix compilation for older systems (#9198)

inherit libs for clock_gettime() when building libmosquitto; Check that X509_VERIFY_PARAM_set1_host is available on the target system
Costa Tsaousis 4 years ago
parent
commit
1ac12904b0
3 changed files with 23 additions and 1 deletions
  1. 4 0
      aclk/aclk_lws_https_client.c
  2. 4 0
      aclk/aclk_lws_wss_client.c
  3. 15 1
      configure.ac

+ 4 - 0
aclk/aclk_lws_https_client.c

@@ -193,6 +193,10 @@ int aclk_send_https_request(char *method, char *host, char *port, char *url, cha
 #else
     i.ssl_connection = LCCSCF_USE_SSL;
 #endif
+#if defined(HAVE_X509_VERIFY_PARAM_set1_host) && HAVE_X509_VERIFY_PARAM_set1_host == 0
+#warning DISABLING SSL HOSTNAME VALIDATION BECAUSE IT IS NOT AVAILABLE ON THIS SYSTEM.
+    i.ssl_connection |= LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK;
+#endif
 
     i.port = atoi(port);
     i.address = host;

+ 4 - 0
aclk/aclk_lws_wss_client.c

@@ -321,6 +321,10 @@ int aclk_lws_wss_connect(char *host, int port)
     info("Disabling SSL certificate checks");
 #else
     i.ssl_connection = LCCSCF_USE_SSL;
+#endif
+#if defined(HAVE_X509_VERIFY_PARAM_set1_host) && HAVE_X509_VERIFY_PARAM_set1_host == 0
+#warning DISABLING SSL HOSTNAME VALIDATION BECAUSE IT IS NOT AVAILABLE ON THIS SYSTEM.
+    i.ssl_connection |= LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK;
 #endif
     lws_client_connect_via_info(&i);
     return 0;

+ 15 - 1
configure.ac

@@ -371,6 +371,20 @@ AC_CHECK_LIB(
     [SSL_LIBS="-lcrypto -lssl"]
 )
 
+AC_CHECK_LIB(
+    [crypto],
+    [X509_VERIFY_PARAM_set1_host],
+    [ssl_host_validation="yes"],
+    [ssl_host_validation="no"]
+)
+
+if test "${ssl_host_validation}" = "no"; then
+    AC_DEFINE([HAVE_X509_VERIFY_PARAM_set1_host], [0], [ssl host validation])
+    AC_MSG_WARN([DISABLING SSL HOSTNAME VALIDATION BECAUSE IT IS NOT AVAILABLE ON THIS SYSTEM.])
+else
+    AC_DEFINE([HAVE_X509_VERIFY_PARAM_set1_host], [1], [ssl host validation])
+fi
+
 # -----------------------------------------------------------------------------
 # JSON-C library
 
@@ -586,7 +600,7 @@ if test "$enable_cloud" != "no"; then
     AC_MSG_CHECKING([if libmosquitto static lib is present (and builds)])
     if test -f "externaldeps/mosquitto/libmosquitto.a"; then
         LIBS_BKP="${LIBS}"
-        LIBS="externaldeps/mosquitto/libmosquitto.a ${OPTIONAL_SSL_LIBS}"
+        LIBS="externaldeps/mosquitto/libmosquitto.a ${OPTIONAL_SSL_LIBS} ${LIBS_BKP}"
         AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/mosquitto/mosquitto.h"
                                          int main (int argc, char **argv) {
                                              int m,mm,r;