- Timestamp:
- 2006-09-24T11:57:45Z (18 years ago)
- Branches:
- master
- Children:
- e101506
- Parents:
- 172a73f1
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/ssl_client.h
r172a73f1 r42127dc 52 52 G_MODULE_EXPORT void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ); 53 53 54 /* Start an SSL session on an existing fd. Useful for STARTTLS functionality, 55 for example in Jabber. */ 56 G_MODULE_EXPORT void *ssl_starttls( int fd, ssl_input_function func, gpointer data ); 57 54 58 /* Obviously you need special read/write functions to read data. */ 55 59 G_MODULE_EXPORT int ssl_read( void *conn, char *buf, int len ); -
lib/ssl_gnutls.c
r172a73f1 r42127dc 63 63 { 64 64 g_free( conn ); 65 return( NULL ); 65 return NULL; 66 } 67 68 return conn; 69 } 70 71 /* FIXME: It can happen that the handshake fails even before ssl_connected() 72 returns already. This function will then return an invalid pointer because 73 these failures can't be detected properly yet. Maybe ssl_connected() 74 shouldn't be called directly, but via a short timeout? */ 75 void *ssl_starttls( int fd, ssl_input_function func, gpointer data ) 76 { 77 struct scd *conn = g_new0( struct scd, 1 ); 78 79 conn->fd = fd; 80 conn->func = func; 81 conn->data = data; 82 conn->inpa = -1; 83 84 ssl_connected( conn, fd, GAIM_INPUT_WRITE ); 85 86 return conn; 87 } 88 89 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); 90 91 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ) 92 { 93 struct scd *conn = data; 94 95 if( source == -1 ) 96 { 97 conn->func( conn->data, NULL, cond ); 98 99 g_free( conn ); 100 101 return FALSE; 66 102 } 67 103 … … 77 113 gnutls_set_default_priority( conn->session ); 78 114 gnutls_credentials_set( conn->session, GNUTLS_CRD_CERTIFICATE, conn->xcred ); 79 80 return( conn );81 }82 83 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond );84 85 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond )86 {87 struct scd *conn = data;88 89 if( source == -1 )90 {91 conn->func( conn->data, NULL, cond );92 93 gnutls_deinit( conn->session );94 gnutls_certificate_free_credentials( conn->xcred );95 96 g_free( conn );97 98 return FALSE;99 }100 115 101 116 sock_make_nonblocking( conn->fd );
Note: See TracChangeset
for help on using the changeset viewer.