]> jfr.im git - irc/znc/Csocket.git/commitdiff
Fix build when OpenSSL is built without SSLv3
authorBernard Spil <redacted>
Fri, 9 Oct 2015 07:04:43 +0000 (09:04 +0200)
committerAlexey Sokolov <redacted>
Sun, 1 Nov 2015 23:47:18 +0000 (23:47 +0000)
If OpenSSL is built without SSLv3 support (configure --no-ssl3), this will fail to build. Patch fixes that. Please see https://github.com/pcbsd/freebsd-ports/blob/master/irc/znc/files/patch-src_Csocket.cpp as well. This is intended to be applied to the FreeBSD ports tree as well.

As a side note: You may wish to refactor the code to only use SSLv23_ methods and set SSL_OP_NO_* using SSL_CTX_set_options. This seems to be the canonical way to be able to negotiate any SSL/TLS version. In addition, OpenSSL 1.1 will be marking SSLv23_ methods as deprecated and replace them with TLS_ methods.
(cherry picked from commit 4dda6ada04fe334cf4a337d9138cc48fc346a992)

Csocket.cc

index 425a4def386cde51339ee4ea59c8e87ab6c0e8a9..15326644b7c091ef3a17b7379dd4b3e2e7212a47 100644 (file)
@@ -1464,6 +1464,7 @@ bool Csock::SSLClientSetup()
 
        switch( m_iMethod )
        {
+#ifndef OPENSSL_NO_SSL3
        case SSL3:
                m_ssl_ctx = SSL_CTX_new( SSLv3_client_method() );
                if( !m_ssl_ctx )
@@ -1472,6 +1473,8 @@ bool Csock::SSLClientSetup()
                        return( false );
                }
                break;
+#endif /* OPENSSL_NO_SSL3 */
+       /* Fall through if SSL3 is disabled */
        case TLS12:
 #if defined( TLS1_2_VERSION ) && defined( OPENSSL_VERSION_NUMBER ) && OPENSSL_VERSION_NUMBER >= 0x1000100f
                m_ssl_ctx = SSL_CTX_new( TLSv1_2_client_method() );
@@ -1586,6 +1589,7 @@ SSL_CTX * Csock::SetupServerCTX()
        SSL_CTX * pCTX = NULL;
        switch( m_iMethod )
        {
+#ifndef OPENSSL_NO_SSL3
        case SSL3:
                pCTX = SSL_CTX_new( SSLv3_server_method() );
                if( !pCTX )
@@ -1594,6 +1598,8 @@ SSL_CTX * Csock::SetupServerCTX()
                        return( NULL );
                }
                break;
+#endif /* OPENSSL_NO_SSL3 */
+       /* Fall through if SSL3 is disabled */
        case TLS12:
 #if defined( TLS1_2_VERSION ) && defined( OPENSSL_VERSION_NUMBER ) && OPENSSL_VERSION_NUMBER >= 0x1000100f
                pCTX = SSL_CTX_new( TLSv1_2_server_method() );