Prevent inexistence of openssl server/client methods from breaking the build
authorNelson Ferreira <nelson.ferreira@ieee.org>
Tue, 15 Nov 2011 08:59:38 +0000 (03:59 -0500)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Tue, 15 Nov 2011 08:59:38 +0000 (03:59 -0500)
Signed-off-by: Nelson Ferreira <nelson.ferreira@ieee.org>
m4/sxe-crypto.m4
src/openssl.c

index 7c1a328..ac95002 100644 (file)
@@ -193,6 +193,30 @@ AC_DEFUN([SXE_CHECK_OPENSSL_FUNCS], [dnl
                SSL_get_peer_cert_chain SSL_pending SSL_get_certificate dnl
                SSL_get_peer_certificate X509_verify_cert_error_string dnl
                SSL_get_verify_result SSL_get_current_cipher SSL_CIPHER_get_bits])
+       if test x"$ac_TLSv1_client_method" = xyes; then
+               AC_DEFINE([HAVE_TLSV1_CLIENT_METHOD], 1, [TLSv1 client methods available])
+       fi
+       if test x"$ac_SSLv2_client_method" = xyes; then
+               AC_DEFINE([HAVE_SSLV2_CLIENT_METHOD], 1, [SSLv2 client methods available])
+       fi
+       if test x"$ac_SSLv3_client_method" = xyes; then
+               AC_DEFINE([HAVE_SSLV3_CLIENT_METHOD], 1, [SSLv3 client methods available])
+       fi
+       if test x"$ac_SSLv23_client_method" = xyes; then
+               AC_DEFINE([HAVE_SSLV23_CLIENT_METHOD], 1, [SSLv23 client methods available])
+       fi
+       if test x"$ac_TLSv1_server_method" = xyes; then
+               AC_DEFINE([HAVE_TLSV1_SERVER_METHOD], 1, [TLSv1 server methods available])
+       fi
+       if test x"$ac_SSLv2_server_method" = xyes; then
+               AC_DEFINE([HAVE_SSLV2_SERVER_METHOD], 1, [SSLv2 server methods available])
+       fi
+       if test x"$ac_SSLv3_server_method" = xyes; then
+               AC_DEFINE([HAVE_SSLV3_SERVER_METHOD], 1, [SSLv3 server methods available])
+       fi
+       if test x"$ac_SSLv23_server_method" = xyes; then
+               AC_DEFINE([HAVE_SSLV23_SERVER_METHOD], 1, [SSLv23 server methods available])
+       fi
        SXE_RESTORE_LIBS
 ])dnl SXE_CHECK_OPENSSL_FUNCS
 
index 309a72b..29d61a6 100644 (file)
@@ -3478,18 +3478,38 @@ ossl_ssl_prepare_cmeth(Lisp_Object method)
        SSL_library_init();
        SSL_load_error_strings();
 
-       if (0);
-       else if (EQ(method, Qssl2))
+       if (0) {
+       } else if (EQ(method, Qssl2)) {
+#if HAVE_SSLV2_CLIENT_METHOD
                meth = (SSL_METHOD *)SSLv2_client_method();
-       else if (EQ(method, Qssl3))
+#else
+               error("sslv2 client method not supported");
+#endif
+       } else if (EQ(method, Qssl3)) {
+#if HAVE_SSLV3_CLIENT_METHOD 
                meth = (SSL_METHOD *)SSLv3_client_method();
-       else if (EQ(method, Qssl23))
+#else
+               error("sslv3 client method not supported");
+#endif
+       } else if (EQ(method, Qssl23)) {
+#if HAVE_SSLV23_CLIENT_METHOD 
                meth = (SSL_METHOD *)SSLv23_client_method();
-       else if (EQ(method, Qtls1))
+#else
+               error("sslv23 client method not supported");
+#endif
+       } else if (EQ(method, Qtls1)) {
+#if HAVE_TLSV1_CLIENT_METHOD 
                meth = (SSL_METHOD *)TLSv1_client_method();
-       else
+#else
+               error("tlsv1 client method not supported");
+#endif
+        } else {
+#if HAVE_TLSV1_CLIENT_METHOD 
                meth = (SSL_METHOD *)TLSv1_client_method();
-
+#else
+               error("default tlsv1 client method not supported");
+#endif
+        }
        if (!RAND_status())
                error("OSSL: not enough random data");
 
@@ -3513,18 +3533,38 @@ ossl_ssl_prepare_smeth(Lisp_Object method)
        SSL_library_init();
        SSL_load_error_strings();
 
-       if (0);
-       else if (EQ(method, Qssl2))
+       if (0) {
+       } else if (EQ(method, Qssl2)) {
+#if HAVE_SSLV2_SERVER_METHOD
                meth = (SSL_METHOD *)SSLv2_server_method();
-       else if (EQ(method, Qssl3))
+#else
+               error("sslv2 client method not supported");
+#endif
+       } else if (EQ(method, Qssl3)) {
+#if HAVE_SSLV3_SERVER_METHOD 
                meth = (SSL_METHOD *)SSLv3_server_method();
-       else if (EQ(method, Qssl23))
+#else
+               error("sslv3 client method not supported");
+#endif
+       } else if (EQ(method, Qssl23)) {
+#if HAVE_SSLV23_SERVER_METHOD 
                meth = (SSL_METHOD *)SSLv23_server_method();
-       else if (EQ(method, Qtls1))
+#else
+               error("sslv23 client method not supported");
+#endif
+       } else if (EQ(method, Qtls1)) {
+#if HAVE_TLSV1_SERVER_METHOD 
                meth = (SSL_METHOD *)TLSv1_server_method();
-       else
+#else
+               error("tlsv1 client method not supported");
+#endif
+       } else {
+#if HAVE_SSLV23_SERVER_METHOD 
                meth = (SSL_METHOD *)SSLv23_server_method();
-
+#else
+               error("default sslv23 client method not supported");
+#endif
+       }
        if (!RAND_status())
                error("OSSL: not enough random data");