# HG changeset patch # User Christian Hammond # Date 1062809244 0 # Node ID 424647996866409d6e0d55efab7f44eecf14dcb6 # Parent ddee8d7daf1b63b7742cc7725c22ab7ad1bde921 [gaim-migrate @ 7290] SSL in GNUTLS no longer blocks everything. Now it uses the input watchers, as it should. committer: Tailor Script diff -r ddee8d7daf1b -r 424647996866 src/ssl-gnutls.c --- a/src/ssl-gnutls.c Fri Sep 05 22:49:59 2003 +0000 +++ b/src/ssl-gnutls.c Sat Sep 06 00:47:24 2003 +0000 @@ -32,7 +32,6 @@ typedef struct { gnutls_session session; - gnutls_certificate_client_credentials xcred; } GaimSslGnutlsData; @@ -46,7 +45,8 @@ gnutls_global_init(); gnutls_certificate_allocate_credentials(&xcred); - gnutls_certificate_set_x509_trust_file(xcred, "ca.pem", GNUTLS_X509_FMT_PEM); + gnutls_certificate_set_x509_trust_file(xcred, "ca.pem", + GNUTLS_X509_FMT_PEM); return TRUE; } @@ -60,12 +60,25 @@ } static void +input_func(gpointer data, gint source, GaimInputCondition cond) +{ + GaimSslConnection *gsc = (GaimSslConnection *)data; + + gaim_debug_misc("gnutls", "In input_func\n"); + + gsc->input_func(gsc->user_data, gsc, cond); +} + +static void ssl_gnutls_connect_cb(gpointer data, gint source, GaimInputCondition cond) { GaimSslConnection *gsc = (GaimSslConnection *)data; GaimSslGnutlsData *gnutls_data; + static const int cert_type_priority[2] = { GNUTLS_CRT_X509, 0 }; int ret; - const int cert_type_priority[2] = { GNUTLS_CRT_X509, 0 }; + + if (source < 0) + return; gsc->fd = source; @@ -88,11 +101,16 @@ if (ret < 0) { + gaim_debug_error("gnutls", "Handshake failed\n"); + + gaim_ssl_close(gsc); } else { - gaim_debug_info("gnutls", "Calling input function\n"); - gsc->input_func(gsc->user_data, (GaimSslConnection *)gsc, cond); + gaim_debug_info("gnutls", "Adding input handler.\n"); + gsc->inpa = gaim_input_add(gsc->fd, + GAIM_INPUT_READ | GAIM_INPUT_WRITE, + input_func, gsc); } } @@ -104,7 +122,6 @@ gnutls_bye(gnutls_data->session, GNUTLS_SHUT_RDWR); gnutls_deinit(gnutls_data->session); -// gnutls_certificate_free_credentials(gnutls_data->xcred); g_free(gnutls_data); } @@ -120,8 +137,6 @@ if (s < 0) s = 0; - gaim_debug_misc("gnutls", "s = %d\n", s); - return s; } @@ -131,9 +146,12 @@ GaimSslGnutlsData *gnutls_data = GAIM_SSL_GNUTLS_DATA(gsc); size_t s; - gaim_debug_misc("gnutls", "Writing: {%s}\n", data); + s = gnutls_record_send(gnutls_data->session, data, len); - s = gnutls_record_send(gnutls_data->session, data, len); + if (s < 0) + s = 0; + + return s; } static GaimSslOps ssl_ops =