Changes in / [1d2e3c2:ec3e411]


Ignore:
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • doc/README

    r1d2e3c2 rec3e411  
    5050
    5151These days, MSN Messenger clients have to connect to the MS Passport servers
    52 through HTTPS. BitlBee can use serveral SSL libraries for this: GnuTLS, NSS
     52through HTTPS. BitlBee can use several SSL libraries for this: GnuTLS, NSS
    5353(which comes with Mozilla) and OpenSSL. OpenSSL is not GPL-compatible in some
    5454situations, so using GnuTLS or NSS is preferred. However, especially on *BSD,
  • protocols/ssl_openssl.c

    r1d2e3c2 rec3e411  
    55  \********************************************************************/
    66
    7 /* SSL module - GnuTLS version                                          */
     7/* SSL module - OpenTLS version                                          */
    88
    99/*
     
    4141struct scd
    4242{
    43         ssl_input_function func;
     43        SslInputFunction func;
    4444        gpointer data;
    4545        int fd;
    4646        gboolean established;
    4747       
    48         int inpa;
    49         int lasterr;            /* Necessary for SSL_get_error */
    5048        SSL *ssl;
    5149        SSL_CTX *ssl_ctx;
     
    5654
    5755
    58 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
     56void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data )
    5957{
    6058        struct scd *conn = g_new0( struct scd, 1 );
     
    9593}
    9694
    97 static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond );
    98 
    9995static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
    10096{
     
    10298       
    10399        if( source == -1 )
    104                 return ssl_handshake( data, -1, cond );
     100                goto ssl_connected_failure;
    105101       
    106         /* Make it non-blocking at least during the handshake... */
    107         sock_make_nonblocking( conn->fd );
    108102        SSL_set_fd( conn->ssl, conn->fd );
    109103       
    110         return ssl_handshake( data, source, cond );
    111 }       
    112 
    113 static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond )
    114 {
    115         struct scd *conn = data;
    116         int st;
    117        
    118         if( conn->inpa != -1 )
    119         {
    120                 gaim_input_remove( conn->inpa );
    121                 conn->inpa = -1;
    122         }
    123        
    124         if( ( st = SSL_connect( conn->ssl ) ) < 0 )
    125         {
    126                 conn->lasterr = SSL_get_error( conn->ssl, st );
    127                 if( conn->lasterr != SSL_ERROR_WANT_READ && conn->lasterr != SSL_ERROR_WANT_WRITE )
    128                         goto ssl_connected_failure;
    129                
    130                 conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data );
    131                 return;
    132         }
     104        if( SSL_connect( conn->ssl ) < 0 )
     105                goto ssl_connected_failure;
    133106       
    134107        conn->established = TRUE;
    135         sock_make_blocking( conn->fd );         /* For now... */
    136108        conn->func( conn->data, conn, cond );
    137109        return;
     
    155127int ssl_read( void *conn, char *buf, int len )
    156128{
    157         int st;
     129        if( !((struct scd*)conn)->established )
     130                return( 0 );
    158131       
    159         if( !((struct scd*)conn)->established )
    160         {
    161                 ssl_errno = SSL_NOHANDSHAKE;
    162                 return -1;
    163         }
    164        
    165         st = SSL_read( ((struct scd*)conn)->ssl, buf, len );
    166        
    167         ssl_errno = SSL_OK;
    168         if( st <= 0 )
    169         {
    170                 ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st );
    171                 if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE )
    172                         ssl_errno = SSL_AGAIN;
    173         }
    174        
    175         return st;
     132        return( SSL_read( ((struct scd*)conn)->ssl, buf, len ) );
    176133}
    177134
    178135int ssl_write( void *conn, const char *buf, int len )
    179136{
    180         int st;
     137        if( !((struct scd*)conn)->established )
     138                return( 0 );
    181139       
    182         if( !((struct scd*)conn)->established )
    183         {
    184                 ssl_errno = SSL_NOHANDSHAKE;
    185                 return -1;
    186         }
    187        
    188         st = SSL_write( ((struct scd*)conn)->ssl, buf, len );
    189        
    190         ssl_errno = SSL_OK;
    191         if( st <= 0 )
    192         {
    193                 ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st );
    194                 if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE )
    195                         ssl_errno = SSL_AGAIN;
    196         }
    197        
    198         return st;
     140        return( SSL_write( ((struct scd*)conn)->ssl, buf, len ) );
    199141}
    200142
     
    202144{
    203145        struct scd *conn = conn_;
    204        
    205         if( conn->inpa != -1 )
    206                 gaim_input_remove( conn->inpa );
    207146       
    208147        if( conn->established )
     
    220159        return( ((struct scd*)conn)->fd );
    221160}
    222 
    223 GaimInputCondition ssl_getdirection( void *conn )
    224 {
    225         return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ );
    226 }
Note: See TracChangeset for help on using the changeset viewer.