Changeset def3650 for lib


Ignore:
Timestamp:
2012-12-24T13:28:02Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
9b67285
Parents:
3f661849
Message:

In the OpenSSL module, keep only one global SSL context instead of recreating
one for every connection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/ssl_openssl.c

    r3f661849 rdef3650  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2004 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2012 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    5252        int lasterr;            /* Necessary for SSL_get_error */
    5353        SSL *ssl;
    54         SSL_CTX *ssl_ctx;
    5554};
     55
     56static SSL_CTX *ssl_ctx;
    5657
    5758static void ssl_conn_free( struct scd *conn );
     
    6364void ssl_init( void )
    6465{
     66        const SSL_METHOD *meth;
     67       
     68        SSL_library_init();
     69       
     70        meth = TLSv1_client_method();
     71        ssl_ctx = SSL_CTX_new( meth );
     72       
    6573        initialized = TRUE;
    66         SSL_library_init();
    67         // SSLeay_add_ssl_algorithms();
    6874}
    6975
     
    122128{
    123129        struct scd *conn = data;
    124         const SSL_METHOD *meth;
    125130       
    126131        if( conn->verify )
     
    142147        }
    143148       
    144         meth = TLSv1_client_method();
    145         conn->ssl_ctx = SSL_CTX_new( meth );
    146         if( conn->ssl_ctx == NULL )
     149       
     150        if( ssl_ctx == NULL )
    147151                goto ssl_connected_failure;
    148152       
    149         conn->ssl = SSL_new( conn->ssl_ctx );
     153        conn->ssl = SSL_new( ssl_ctx );
    150154        if( conn->ssl == NULL )
    151155                goto ssl_connected_failure;
     
    251255{
    252256        SSL_free( conn->ssl );
    253         SSL_CTX_free( conn->ssl_ctx );
    254257        g_free( conn->hostname );
    255258        g_free( conn );
Note: See TracChangeset for help on using the changeset viewer.