sslconn.h
Go to the documentation of this file.
1
6 /* purple
7 *
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 */
26 #ifndef _PURPLE_SSLCONN_H_
27 #define _PURPLE_SSLCONN_H_
28
30 typedef enum
31 {
32 PURPLE_SSL_HANDSHAKE_FAILED = 1,
33 PURPLE_SSL_CONNECT_FAILED = 2,
34 PURPLE_SSL_CERTIFICATE_INVALID = 3
35 } PurpleSslErrorType;
36
37 #include "certificate.h"
38 #include "proxy.h"
39
40 #define PURPLE_SSL_DEFAULT_PORT 443
41
43 typedef struct _PurpleSslConnection PurpleSslConnection;
44
45 typedef void (*PurpleSslInputFunction)(gpointer, PurpleSslConnection *,
46 PurpleInputCondition);
47 typedef void (*PurpleSslErrorFunction)(PurpleSslConnection *, PurpleSslErrorType,
48 gpointer);
49
50 struct _PurpleSslConnection
51 {
53 char *host;
55 int port;
57 void *connect_cb_data;
59 PurpleSslInputFunction connect_cb;
61 PurpleSslErrorFunction error_cb;
63 void *recv_cb_data;
65 PurpleSslInputFunction recv_cb;
66
68 int fd;
71 guint inpa;
73 PurpleProxyConnectData *connect_data;
74
76 void *private_data;
77
79 PurpleCertificateVerifier *verifier;
80 };
81
88 typedef struct
89 {
94 gboolean (*init)(void);
98 void (*uninit)(void);
103 void (*connectfunc)(PurpleSslConnection *gsc);
108 void (*close)(PurpleSslConnection *gsc);
117 size_t (*read)(PurpleSslConnection *gsc, void *data, size_t len);
126 size_t (*write)(PurpleSslConnection *gsc, const void *data, size_t len);
136 GList * (* get_peer_certificates)(PurpleSslConnection * gsc);
137
138 void (*_purple_reserved2)(void);
139 void (*_purple_reserved3)(void);
140 void (*_purple_reserved4)(void);
141 } PurpleSslOps;
142
143 #ifdef __cplusplus
144 extern "C" {
145 #endif
146
147 /**************************************************************************/
149 /**************************************************************************/
157 gboolean purple_ssl_is_supported(void);
158
165 const gchar * purple_ssl_strerror(PurpleSslErrorType error);
166
184 PurpleSslConnection *purple_ssl_connect(PurpleAccount *account, const char *host,
185 int port, PurpleSslInputFunction func,
186 PurpleSslErrorFunction error_func,
187 void *data);
188
208 PurpleSslConnection *purple_ssl_connect_with_ssl_cn(PurpleAccount *account, const char *host,
209 int port, PurpleSslInputFunction func,
210 PurpleSslErrorFunction error_func,
211 const char *ssl_host,
212 void *data);
213
214 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_SSLCONN_C_)
215
228 PurpleSslConnection *purple_ssl_connect_fd(PurpleAccount *account, int fd,
229 PurpleSslInputFunction func,
230 PurpleSslErrorFunction error_func,
231 void *data);
232 #endif
233
248 PurpleSslConnection *purple_ssl_connect_with_host_fd(PurpleAccount *account, int fd,
249 PurpleSslInputFunction func,
250 PurpleSslErrorFunction error_func,
251 const char *host,
252 void *data);
253
262 void purple_ssl_input_add(PurpleSslConnection *gsc, PurpleSslInputFunction func,
263 void *data);
264
270 void purple_ssl_close(PurpleSslConnection *gsc);
271
281 size_t purple_ssl_read(PurpleSslConnection *gsc, void *buffer, size_t len);
282
292 size_t purple_ssl_write(PurpleSslConnection *gsc, const void *buffer, size_t len);
293
304 GList * purple_ssl_get_peer_certificates(PurpleSslConnection *gsc);
305
308 /**************************************************************************/
310 /**************************************************************************/
318 void purple_ssl_set_ops(PurpleSslOps *ops);
319
325 PurpleSslOps *purple_ssl_get_ops(void);
326
330 void purple_ssl_init(void);
331
335 void purple_ssl_uninit(void);
336
339 #ifdef __cplusplus
340 }
341 #endif
342
343 #endif /* _PURPLE_SSLCONN_H_ */
purple_ssl_get_ops
PurpleSslOps * purple_ssl_get_ops(void)
Returns the current SSL operations structure.
_PurpleCertificateVerifier
A set of operations used to provide logic for verifying a Certificate&#39;s authenticity.
Definition: certificate.h:362
_PurpleSslConnection::verifier
PurpleCertificateVerifier * verifier
Verifier to use in authenticating the peer.
Definition: sslconn.h:79
purple_ssl_is_supported
gboolean purple_ssl_is_supported(void)
Returns whether or not SSL is currently supported.
_PurpleSslConnection::connect_cb_data
void * connect_cb_data
Data to pass to PurpleSslConnection::connect_cb()
Definition: sslconn.h:57
purple_ssl_connect
PurpleSslConnection * purple_ssl_connect(PurpleAccount *account, const char *host, int port, PurpleSslInputFunction func, PurpleSslErrorFunction error_func, void *data)
Makes a SSL connection to the specified host and port.
_PurpleSslConnection::connect_cb
PurpleSslInputFunction connect_cb
Callback triggered once the SSL handshake is complete.
Definition: sslconn.h:59
certificate.h
Public-Key Certificate API.
purple_ssl_write
size_t purple_ssl_write(PurpleSslConnection *gsc, const void *buffer, size_t len)
Writes data to an SSL connection.
_PurpleAccount
Structure representing an account.
Definition: account.h:169
_PurpleSslConnection::error_cb
PurpleSslErrorFunction error_cb
Callback triggered if there is an error during connection.
Definition: sslconn.h:61
purple_ssl_get_peer_certificates
GList * purple_ssl_get_peer_certificates(PurpleSslConnection *gsc)
Obtains the peer&#39;s presented certificates.
purple_ssl_close
void purple_ssl_close(PurpleSslConnection *gsc)
Closes a SSL connection.
_PurpleSslConnection::port
int port
Port to connect to.
Definition: sslconn.h:55
purple_ssl_init
void purple_ssl_init(void)
Initializes the SSL subsystem.
purple_ssl_connect_with_host_fd
PurpleSslConnection * purple_ssl_connect_with_host_fd(PurpleAccount *account, int fd, PurpleSslInputFunction func, PurpleSslErrorFunction error_func, const char *host, void *data)
Makes a SSL connection using an already open file descriptor.
purple_ssl_uninit
void purple_ssl_uninit(void)
Uninitializes the SSL subsystem.
purple_ssl_connect_with_ssl_cn
PurpleSslConnection * purple_ssl_connect_with_ssl_cn(PurpleAccount *account, const char *host, int port, PurpleSslInputFunction func, PurpleSslErrorFunction error_func, const char *ssl_host, void *data)
Makes a SSL connection to the specified host and port, using the separate name to verify with the cer...
_PurpleSslConnection::fd
int fd
File descriptor used to refer to the socket.
Definition: sslconn.h:68
_PurpleSslConnection::private_data
void * private_data
Internal connection data managed by the SSL backend (GnuTLS/LibNSS/whatever)
Definition: sslconn.h:76
PurpleInputCondition
PurpleInputCondition
An input condition.
Definition: eventloop.h:38
_PurpleSslConnection::recv_cb
PurpleSslInputFunction recv_cb
User-defined callback executed when the SSL connection receives data.
Definition: sslconn.h:65
purple_ssl_input_add
void purple_ssl_input_add(PurpleSslConnection *gsc, PurpleSslInputFunction func, void *data)
Adds an input watcher for the specified SSL connection.
PurpleSslErrorType
PurpleSslErrorType
Possible SSL errors.
Definition: sslconn.h:30
_PurpleSslConnection::inpa
guint inpa
Glib event source ID; used to refer to the received data callback in the glib eventloop.
Definition: sslconn.h:71
_PurpleSslConnection
Definition: sslconn.h:50
proxy.h
Proxy API.
purple_ssl_set_ops
void purple_ssl_set_ops(PurpleSslOps *ops)
Sets the current SSL operations structure.
_PurpleSslConnection::host
char * host
Hostname to which the SSL connection will be made.
Definition: sslconn.h:53
purple_ssl_read
size_t purple_ssl_read(PurpleSslConnection *gsc, void *buffer, size_t len)
Reads data from an SSL connection.
purple_ssl_strerror
const gchar * purple_ssl_strerror(PurpleSslErrorType error)
Returns a human-readable string for an SSL error.
_PurpleSslConnection::connect_data
PurpleProxyConnectData * connect_data
Data related to the underlying TCP connection.
Definition: sslconn.h:73
PurpleSslOps
SSL implementation operations structure.
Definition: sslconn.h:88
purple_ssl_connect_fd
PurpleSslConnection * purple_ssl_connect_fd(PurpleAccount *account, int fd, PurpleSslInputFunction func, PurpleSslErrorFunction error_func, void *data)
Makes a SSL connection using an already open file descriptor.
_PurpleSslConnection::recv_cb_data
void * recv_cb_data
Data passed to PurpleSslConnection::recv_cb()
Definition: sslconn.h:63