You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@serf.apache.org by as...@apache.org on 2017/08/18 19:37:41 UTC

svn commit: r1805462 - in /serf/trunk: SConstruct buckets/ssl_buckets.c

Author: astieger
Date: Fri Aug 18 19:37:41 2017
New Revision: 1805462

URL: http://svn.apache.org/viewvc?rev=1805462&view=rev
Log:
Fix build with OpenSSL 1.1.x

* SConstruct: fix if OPENSSL_malloc_init is a macro,
  check for OSSL_HANDSHAKE_STATE type for TLS_ST_SW_HELLO_REQ
* buckets/ssl_buckets.c: use SERF_HAVE_OSSL_HANDSHAKE_STATE

Modified:
    serf/trunk/SConstruct
    serf/trunk/buckets/ssl_buckets.c

Modified: serf/trunk/SConstruct
URL: http://svn.apache.org/viewvc/serf/trunk/SConstruct?rev=1805462&r1=1805461&r2=1805462&view=diff
==============================================================================
--- serf/trunk/SConstruct (original)
+++ serf/trunk/SConstruct Fri Aug 18 19:37:41 2017
@@ -8,9 +8,9 @@
 #    to you under the Apache License, Version 2.0 (the
 #    "License"); you may not use this file except in compliance
 #    with the License.  You may obtain a copy of the License at
-# 
+#
 #      http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 #    Unless required by applicable law or agreed to in writing,
 #    software distributed under the License is distributed on an
 #    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -123,7 +123,7 @@ opts.AddVariables(
   RawListVariable('LINKFLAGS', "Extra flags for the linker (space-separated)",
                   None),
   RawListVariable('CPPFLAGS', "Extra flags for the C preprocessor "
-                  "(space separated)", None), 
+                  "(space separated)", None),
   )
 
 if sys.platform == 'win32':
@@ -173,7 +173,7 @@ env = Environment(variables=opts,
 gen_def_script = env.File('build/gen_def.py').rstr()
 
 env.Append(BUILDERS = {
-    'GenDef' : 
+    'GenDef' :
       Builder(action = sys.executable + ' %s $SOURCES > $TARGET' % (gen_def_script,),
               suffix='.def', src_suffix='.h')
   })
@@ -456,8 +456,13 @@ if conf.CheckFunc('CRYPTO_set_locking_ca
   env.Append(CPPDEFINES=['SERF_HAVE_SSL_LOCKING_CALLBACKS'])
 if conf.CheckFunc('OPENSSL_malloc_init'):
   env.Append(CPPDEFINES=['SERF_HAVE_OPENSSL_MALLOC_INIT'])
+# In OpenSSL 1.1.x, OPENSSL_malloc_init is a function macro
+if conf.CheckDeclaration('OPENSSL_malloc_init()'):
+  env.Append(CPPDEFINES=['SERF_HAVE_OPENSSL_MALLOC_INIT'])
 if conf.CheckFunc('SSL_set_alpn_protos'):
   env.Append(CPPDEFINES=['SERF_HAVE_OPENSSL_ALPN'])
+if conf.CheckType('OSSL_HANDSHAKE_STATE', '#include <openssl/ssl.h>'):
+  env.Append(CPPDEFINES=['SERF_HAVE_OSSL_HANDSHAKE_STATE'])
 env = conf.Finish()
 
 # If build with gssapi, get its information and define SERF_HAVE_GSSAPI

Modified: serf/trunk/buckets/ssl_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/ssl_buckets.c?rev=1805462&r1=1805461&r2=1805462&view=diff
==============================================================================
--- serf/trunk/buckets/ssl_buckets.c (original)
+++ serf/trunk/buckets/ssl_buckets.c Fri Aug 18 19:37:41 2017
@@ -299,12 +299,13 @@ detect_renegotiate(const SSL *s, int whe
 #endif
 
     /* The server asked to renegotiate the SSL session. */
-#ifdef TLS_ST_SW_HELLO_REQ
+#ifdef SERF_HAVE_OSSL_HANDSHAKE_STATE
     if (SSL_get_state(s) == TLS_ST_SW_HELLO_REQ) {
 #elif defined(SSL_ST_RENEGOTIATE)
     if (SSL_state(s) == SSL_ST_RENEGOTIATE) {
 #else
 #error "neither TLS_ST_SW_HELLO_REQ nor SSL_ST_RENEGOTIATE is available"
+    {
 #endif
         serf_ssl_context_t *ssl_ctx = SSL_get_app_data(s);
 
@@ -1111,7 +1112,7 @@ static apr_status_t ssl_decrypt(void *ba
         /* Once we got through the initial handshake, we should have received
            the ALPN information if there is such information. */
         ctx->handshake_finished = SSL_is_init_finished(ctx->ssl)
-#ifdef TLS_ST_OK
+#ifdef SERF_HAVE_OSSL_HANDSHAKE_STATE
                                   || (SSL_get_state(ctx->ssl) == TLS_ST_OK);
 #elif defined(SSL_CB_HANDSHAKE_DONE)
                                   || (SSL_state(ctx->ssl)