Changeset 164352e for lib/ssl_openssl.c


Ignore:
Timestamp:
2011-12-24T18:02:39Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
34ded90
Parents:
e306fbf (diff), 96f954d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging mainline.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/ssl_openssl.c

    re306fbf r164352e  
    4545        int fd;
    4646        gboolean established;
     47        gboolean verify;
    4748       
    4849        int inpa;
     
    6465}
    6566
    66 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
     67void *ssl_connect( char *host, int port, gboolean verify, ssl_input_function func, gpointer data )
    6768{
    6869        struct scd *conn = g_new0( struct scd, 1 );
     
    8283}
    8384
    84 void *ssl_starttls( int fd, ssl_input_function func, gpointer data )
     85void *ssl_starttls( int fd, char *hostname, gboolean verify, ssl_input_function func, gpointer data )
    8586{
    8687        struct scd *conn = g_new0( struct scd, 1 );
     
    9091        conn->data = data;
    9192        conn->inpa = -1;
     93        conn->verify = verify && global.conf->cafile;
    9294       
    9395        /* This function should be called via a (short) timeout instead of
     
    117119        SSL_METHOD *meth;
    118120       
     121        /* Right now we don't have any verification functionality for OpenSSL. */
     122
     123        if( conn->verify )
     124        {
     125                conn->func( conn->data, 1, NULL, cond );
     126                if( source >= 0 ) closesocket( source );
     127                g_free( conn );
     128
     129                return FALSE;
     130        }
     131
    119132        if( source == -1 )
    120133                goto ssl_connected_failure;
     
    141154
    142155ssl_connected_failure:
    143         conn->func( conn->data, NULL, cond );
     156        conn->func( conn->data, 0, NULL, cond );
    144157       
    145158        if( conn->ssl )
     
    169182                if( conn->lasterr != SSL_ERROR_WANT_READ && conn->lasterr != SSL_ERROR_WANT_WRITE )
    170183                {
    171                         conn->func( conn->data, NULL, cond );
     184                        conn->func( conn->data, 0, NULL, cond );
    172185                       
    173186                        SSL_shutdown( conn->ssl );
     
    187200        conn->established = TRUE;
    188201        sock_make_blocking( conn->fd );         /* For now... */
    189         conn->func( conn->data, conn, cond );
     202        conn->func( conn->data, 0, conn, cond );
    190203        return FALSE;
    191204}
     
    272285{
    273286        return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? B_EV_IO_WRITE : B_EV_IO_READ );
     287}
     288
     289char *ssl_verify_strerror( int code )
     290{
     291        return g_strdup( "SSL certificate verification not supported by BitlBee OpenSSL code." );
    274292}
    275293
Note: See TracChangeset for help on using the changeset viewer.