Changeset 792a93b for protocols/jabber


Ignore:
Timestamp:
2011-12-23T12:44:08Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
200e151
Parents:
2d93a51e (diff), 41658da (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 SSL certificate verification for GnuTLS, with help from AopicieR.

Location:
protocols/jabber
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    r2d93a51e r792a93b  
    279279}
    280280
    281 gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond )
     281gboolean jabber_connected_ssl( gpointer data, int returncode, void *source, b_input_condition cond )
    282282{
    283283        struct im_connection *ic = data;
     
    295295                jd->ssl = NULL;
    296296               
    297                 imcb_error( ic, "Could not connect to server" );
    298                 imc_logout( ic, TRUE );
     297                if( returncode != 0 )
     298                {
     299                        char *err = ssl_verify_strerror( returncode );
     300                        imcb_error( ic, "Certificate verification problem 0x%x: %s",
     301                                    returncode, err ? err : "Unknown" );
     302                        g_free( err );
     303                        imc_logout( ic, FALSE );
     304                }
     305                else
     306                {
     307                        imcb_error( ic, "Could not connect to server" );
     308                        imc_logout( ic, TRUE );
     309                }
     310               
    299311                return FALSE;
    300312        }
     
    400412        struct im_connection *ic = data;
    401413        struct jabber_data *jd = ic->proto_data;
    402         char *xmlns;
     414        char *xmlns, *tlsname;
    403415       
    404416        xmlns = xt_find_attr( node, "xmlns" );
     
    426438       
    427439        jd->flags |= JFLAG_STARTTLS_DONE;
    428         jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic );
     440
     441        /* If the user specified a server for the account, use this server as the
     442         * hostname in the certificate verification. Else we use the domain from
     443         * the username. */
     444        if( ic->acc->server && *ic->acc->server )
     445                tlsname = ic->acc->server;
     446        else
     447                tlsname = jd->server;
     448       
     449        jd->ssl = ssl_starttls( jd->fd, tlsname, set_getbool( &ic->acc->set, "tls_verify" ),
     450                                jabber_connected_ssl, ic );
    429451       
    430452        return XT_HANDLED;
  • protocols/jabber/jabber.c

    r2d93a51e r792a93b  
    8080       
    8181        s = set_add( &acc->set, "tls", "try", set_eval_tls, acc );
     82        s->flags |= ACC_SET_OFFLINE_ONLY;
     83       
     84        s = set_add( &acc->set, "tls_verify", "true", set_eval_bool, acc );
    8285        s->flags |= ACC_SET_OFFLINE_ONLY;
    8386       
     
    233236        if( set_getbool( &acc->set, "ssl" ) )
    234237        {
    235                 jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, ic );
     238                jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), FALSE, jabber_connected_ssl, ic );
    236239                jd->fd = jd->ssl ? ssl_getfd( jd->ssl ) : -1;
    237240        }
  • protocols/jabber/jabber.h

    r2d93a51e r792a93b  
    309309int jabber_write( struct im_connection *ic, char *buf, int len );
    310310gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond );
    311 gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond );
     311gboolean jabber_connected_ssl( gpointer data, int returncode, void *source, b_input_condition cond );
    312312gboolean jabber_start_stream( struct im_connection *ic );
    313313void jabber_end_stream( struct im_connection *ic );
Note: See TracChangeset for help on using the changeset viewer.