Wed, 05 Sep 2007 22:32:14 +0000
propagate from branch 'im.pidgin.pidgin' (head 0853a065e5c3fcb5a6bb13fc23bec44ecf510ecd)
to branch 'im.pidgin.soc.2007.xmpp' (head b273d0db2bdd4a80d0fb22d32fe186e1f496933f)
| 6703 | 1 | /** |
| 2 | * @file sslconn.h SSL API | |
| 3 | * @ingroup core | |
| 4 | * | |
| 15884 | 5 | * purple |
| 6703 | 6 | * |
| 15884 | 7 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 8 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 9 | * source distribution. | |
| 6703 | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | */ | |
| 15884 | 25 | #ifndef _PURPLE_SSLCONN_H_ |
| 26 | #define _PURPLE_SSLCONN_H_ | |
| 6703 | 27 | |
|
18464
7fb7cb707a19
- Add verifier field to SslConnection
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18451
diff
changeset
|
28 | #include "certificate.h" |
| 6703 | 29 | #include "proxy.h" |
| 30 | ||
| 15884 | 31 | #define PURPLE_SSL_DEFAULT_PORT 443 |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
32 | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
33 | typedef enum |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
34 | { |
| 15884 | 35 | PURPLE_SSL_HANDSHAKE_FAILED = 1, |
|
18474
7f5cf3fa528d
- Add PURPLE_SSL_CERTIFICATE_INVALID error code
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18464
diff
changeset
|
36 | PURPLE_SSL_CONNECT_FAILED = 2, |
|
7f5cf3fa528d
- Add PURPLE_SSL_CERTIFICATE_INVALID error code
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18464
diff
changeset
|
37 | PURPLE_SSL_CERTIFICATE_INVALID = 3 |
| 15884 | 38 | } PurpleSslErrorType; |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
39 | |
| 15884 | 40 | typedef struct _PurpleSslConnection PurpleSslConnection; |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
41 | |
| 15884 | 42 | typedef void (*PurpleSslInputFunction)(gpointer, PurpleSslConnection *, |
| 43 | PurpleInputCondition); | |
| 44 | typedef void (*PurpleSslErrorFunction)(PurpleSslConnection *, PurpleSslErrorType, | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
45 | gpointer); |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
46 | |
| 15884 | 47 | struct _PurpleSslConnection |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
48 | { |
|
17314
db5063b444df
Partial documentation on SslConnection struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17313
diff
changeset
|
49 | /** Hostname to which the SSL connection will be made */ |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
50 | char *host; |
|
17314
db5063b444df
Partial documentation on SslConnection struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17313
diff
changeset
|
51 | /** Port to connect to */ |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
52 | int port; |
|
17315
b6976c48ec78
More documenting
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17314
diff
changeset
|
53 | /** Data to pass to PurpleSslConnection::connect_cb() */ |
| 6764 | 54 | void *connect_cb_data; |
|
17315
b6976c48ec78
More documenting
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17314
diff
changeset
|
55 | /** Callback triggered once the SSL handshake is complete */ |
| 15884 | 56 | PurpleSslInputFunction connect_cb; |
|
17316
a511aef67b4f
- Completed SslConnection fields docs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17315
diff
changeset
|
57 | /** Callback triggered if there is an error during connection */ |
| 15884 | 58 | PurpleSslErrorFunction error_cb; |
|
17315
b6976c48ec78
More documenting
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17314
diff
changeset
|
59 | /** Data passed to PurpleSslConnection::recv_cb() */ |
| 6764 | 60 | void *recv_cb_data; |
|
17316
a511aef67b4f
- Completed SslConnection fields docs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17315
diff
changeset
|
61 | /** User-defined callback executed when the SSL connection receives data */ |
| 15884 | 62 | PurpleSslInputFunction recv_cb; |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
63 | |
|
17314
db5063b444df
Partial documentation on SslConnection struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17313
diff
changeset
|
64 | /** File descriptor used to refer to the socket */ |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
65 | int fd; |
|
17316
a511aef67b4f
- Completed SslConnection fields docs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17315
diff
changeset
|
66 | /** Glib event source ID; used to refer to the received data callback |
|
a511aef67b4f
- Completed SslConnection fields docs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17315
diff
changeset
|
67 | * in the glib eventloop */ |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
68 | int inpa; |
|
17316
a511aef67b4f
- Completed SslConnection fields docs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17315
diff
changeset
|
69 | /** Data related to the underlying TCP connection */ |
| 15884 | 70 | PurpleProxyConnectData *connect_data; |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
71 | |
|
17314
db5063b444df
Partial documentation on SslConnection struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17313
diff
changeset
|
72 | /** Internal connection data managed by the SSL backend (GnuTLS/LibNSS/whatever) */ |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
73 | void *private_data; |
|
18464
7fb7cb707a19
- Add verifier field to SslConnection
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18451
diff
changeset
|
74 | |
|
7fb7cb707a19
- Add verifier field to SslConnection
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18451
diff
changeset
|
75 | /** Verifier to use in authenticating the peer */ |
|
7fb7cb707a19
- Add verifier field to SslConnection
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18451
diff
changeset
|
76 | PurpleCertificateVerifier *verifier; |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
77 | }; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
78 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
79 | /** |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
80 | * SSL implementation operations structure. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
81 | * |
|
17315
b6976c48ec78
More documenting
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17314
diff
changeset
|
82 | * Every SSL implementation must provide all of these and register it via purple_ssl_set_ops() |
|
17313
c8b649e48d4f
Clarify documentation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17312
diff
changeset
|
83 | * These should not be called directly! Instead, use the purple_ssl_* functions. |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
84 | */ |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
85 | typedef struct |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
86 | { |
|
17312
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
87 | /** Initializes the SSL system provided. |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
88 | * @return TRUE if initialization succeeded |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
89 | */ |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
90 | gboolean (*init)(void); |
|
17312
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
91 | /** Unloads the SSL system. Inverse of init. */ |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
92 | void (*uninit)(void); |
|
17312
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
93 | /** Sets up the SSL connection for a PurpleSslConnection once |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
94 | * the TCP connection has been established */ |
| 15884 | 95 | void (*connectfunc)(PurpleSslConnection *gsc); |
|
17313
c8b649e48d4f
Clarify documentation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17312
diff
changeset
|
96 | /** Destroys the internal data of the SSL connection provided. |
|
c8b649e48d4f
Clarify documentation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17312
diff
changeset
|
97 | * Freeing gsc itself is left to purple_ssl_close() |
|
c8b649e48d4f
Clarify documentation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17312
diff
changeset
|
98 | * |
|
c8b649e48d4f
Clarify documentation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17312
diff
changeset
|
99 | */ |
| 15884 | 100 | void (*close)(PurpleSslConnection *gsc); |
|
17312
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
101 | /** Reads data from a connection (like POSIX read()) |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
102 | * @param gsc Connection context |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
103 | * @param data Pointer to buffer to drop data into |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
104 | * @param len Maximum number of bytes to read |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
105 | * @return Number of bytes actually written into the buffer, or <0 on error |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
106 | */ |
| 15884 | 107 | size_t (*read)(PurpleSslConnection *gsc, void *data, size_t len); |
|
17312
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
108 | /** Writes data to a connection (like POSIX send()) |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
109 | * @param gsc Connection context |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
110 | * @param data Data buffer to send data from |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
111 | * @param len Number of bytes to send from buffer |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
112 | * @return The number of bytes written (may be less than len) or <0 on error |
|
ba4bc8d967f8
Documented the SslOps structure
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16743
diff
changeset
|
113 | */ |
| 15884 | 114 | size_t (*write)(PurpleSslConnection *gsc, const void *data, size_t len); |
|
18246
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
115 | /** Obtains the certificate chain provided by the peer |
|
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
116 | * |
|
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
117 | * @param gsc Connection context |
|
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
118 | * @return A newly allocated list containing the certificates |
|
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
119 | * the peer provided. |
|
18464
7fb7cb707a19
- Add verifier field to SslConnection
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18451
diff
changeset
|
120 | * @see PurpleCertificate |
|
18246
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
121 | * @todo Decide whether the ordering of certificates in this |
|
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
122 | * list can be guaranteed. |
|
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
123 | */ |
|
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
124 | GList * (* get_peer_certificates)(PurpleSslConnection * gsc); |
|
212bfb9c9cc7
- Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17430
diff
changeset
|
125 | |
|
16743
1ce5ffe12e2a
Initial addition of padding for ui_ops and other class-like structs
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
126 | void (*_purple_reserved2)(void); |
|
1ce5ffe12e2a
Initial addition of padding for ui_ops and other class-like structs
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
127 | void (*_purple_reserved3)(void); |
|
1ce5ffe12e2a
Initial addition of padding for ui_ops and other class-like structs
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
128 | void (*_purple_reserved4)(void); |
| 15884 | 129 | } PurpleSslOps; |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
130 | |
| 6703 | 131 | #ifdef __cplusplus |
| 132 | extern "C" { | |
| 133 | #endif | |
| 134 | ||
| 135 | /**************************************************************************/ | |
| 136 | /** @name SSL API */ | |
| 137 | /**************************************************************************/ | |
| 138 | /*@{*/ | |
| 139 | ||
| 140 | /** | |
| 141 | * Returns whether or not SSL is currently supported. | |
| 142 | * | |
| 143 | * @return TRUE if SSL is supported, or FALSE otherwise. | |
| 144 | */ | |
| 15884 | 145 | gboolean purple_ssl_is_supported(void); |
| 6703 | 146 | |
| 147 | /** | |
|
18487
0730e45141fd
- Add purple_ssl_strerror for handy error description power!
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18474
diff
changeset
|
148 | * Returns a human-readable string for an SSL error |
|
0730e45141fd
- Add purple_ssl_strerror for handy error description power!
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18474
diff
changeset
|
149 | * |
|
0730e45141fd
- Add purple_ssl_strerror for handy error description power!
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18474
diff
changeset
|
150 | * @param error Error code |
|
0730e45141fd
- Add purple_ssl_strerror for handy error description power!
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18474
diff
changeset
|
151 | * @return Human-readable error explanation |
|
0730e45141fd
- Add purple_ssl_strerror for handy error description power!
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18474
diff
changeset
|
152 | */ |
|
0730e45141fd
- Add purple_ssl_strerror for handy error description power!
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18474
diff
changeset
|
153 | const gchar * purple_ssl_strerror(PurpleSslErrorType error); |
|
0730e45141fd
- Add purple_ssl_strerror for handy error description power!
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18474
diff
changeset
|
154 | |
|
0730e45141fd
- Add purple_ssl_strerror for handy error description power!
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18474
diff
changeset
|
155 | /** |
|
14312
6ce4512aa9a8
[gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
156 | * Makes a SSL connection to the specified host and port. The caller |
|
6ce4512aa9a8
[gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
157 | * should keep track of the returned value and use it to cancel the |
|
6ce4512aa9a8
[gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
158 | * connection, if needed. |
| 6703 | 159 | * |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
160 | * @param account The account making the connection. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
161 | * @param host The destination host. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
162 | * @param port The destination port. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
163 | * @param func The SSL input handler function. |
|
14312
6ce4512aa9a8
[gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
164 | * @param error_func The SSL error handler function. This function |
| 15884 | 165 | * should NOT call purple_ssl_close(). In the event |
| 166 | * of an error the PurpleSslConnection will be | |
|
14312
6ce4512aa9a8
[gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
167 | * destroyed for you. |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
168 | * @param data User-defined data. |
| 6703 | 169 | * |
| 170 | * @return The SSL connection handle. | |
| 171 | */ | |
| 15884 | 172 | PurpleSslConnection *purple_ssl_connect(PurpleAccount *account, const char *host, |
| 173 | int port, PurpleSslInputFunction func, | |
| 174 | PurpleSslErrorFunction error_func, | |
| 6703 | 175 | void *data); |
| 176 | ||
| 177 | /** | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
178 | * Makes a SSL connection using an already open file descriptor. |
|
18449
2d2df64f4303
applied changes from f9186fabb483b56a9d7e8fb7241b2520e9930413
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18246
diff
changeset
|
179 | * DEPRECATED. Use purple_ssl_connect_with_host_fd instead. |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
180 | * |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
181 | * @param account The account making the connection. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
182 | * @param fd The file descriptor. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
183 | * @param func The SSL input handler function. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
184 | * @param error_func The SSL error handler function. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
185 | * @param data User-defined data. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
186 | * |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
187 | * @return The SSL connection handle. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
188 | */ |
| 15884 | 189 | PurpleSslConnection *purple_ssl_connect_fd(PurpleAccount *account, int fd, |
| 190 | PurpleSslInputFunction func, | |
| 191 | PurpleSslErrorFunction error_func, | |
|
17765
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
192 | void *data); |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
193 | |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
194 | /** |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
195 | * Makes a SSL connection using an already open file descriptor. |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
196 | * |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
197 | * @param account The account making the connection. |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
198 | * @param fd The file descriptor. |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
199 | * @param func The SSL input handler function. |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
200 | * @param error_func The SSL error handler function. |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
201 | * @param host The hostname of the other peer (to verify the CN) |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
202 | * @param data User-defined data. |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
203 | * |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
204 | * @return The SSL connection handle. |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
205 | */ |
|
18449
2d2df64f4303
applied changes from f9186fabb483b56a9d7e8fb7241b2520e9930413
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18246
diff
changeset
|
206 | PurpleSslConnection *purple_ssl_connect_with_host_fd(PurpleAccount *account, int fd, |
|
17765
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
207 | PurpleSslInputFunction func, |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
208 | PurpleSslErrorFunction error_func, |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
209 | const char *host, |
|
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17344
diff
changeset
|
210 | void *data); |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
211 | |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
212 | /** |
| 6764 | 213 | * Adds an input watcher for the specified SSL connection. |
|
17344
158859c42ae9
Add note on use of purple_ssl_input_add
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17316
diff
changeset
|
214 | * Once the SSL handshake is complete, use this to watch for actual data across it. |
| 6764 | 215 | * |
| 216 | * @param gsc The SSL connection handle. | |
| 217 | * @param func The callback function. | |
| 218 | * @param data User-defined data. | |
| 219 | */ | |
| 15884 | 220 | void purple_ssl_input_add(PurpleSslConnection *gsc, PurpleSslInputFunction func, |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
221 | void *data); |
|
6762
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6738
diff
changeset
|
222 | |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6738
diff
changeset
|
223 | /** |
| 6703 | 224 | * Closes a SSL connection. |
| 225 | * | |
| 226 | * @param gsc The SSL connection to close. | |
| 227 | */ | |
| 15884 | 228 | void purple_ssl_close(PurpleSslConnection *gsc); |
| 6703 | 229 | |
| 230 | /** | |
| 231 | * Reads data from an SSL connection. | |
| 232 | * | |
| 233 | * @param gsc The SSL connection handle. | |
| 234 | * @param buffer The destination buffer. | |
| 235 | * @param len The maximum number of bytes to read. | |
| 236 | * | |
| 237 | * @return The number of bytes read. | |
| 238 | */ | |
| 15884 | 239 | size_t purple_ssl_read(PurpleSslConnection *gsc, void *buffer, size_t len); |
| 6703 | 240 | |
| 241 | /** | |
| 242 | * Writes data to an SSL connection. | |
| 243 | * | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
244 | * @param gsc The SSL connection handle. |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
245 | * @param buffer The buffer to write. |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
246 | * @param len The length of the data to write. |
| 6703 | 247 | * |
| 248 | * @return The number of bytes written. | |
| 249 | */ | |
| 15884 | 250 | size_t purple_ssl_write(PurpleSslConnection *gsc, const void *buffer, size_t len); |
| 6703 | 251 | |
|
18451
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
252 | /** |
|
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
253 | * Obtains the peer's presented certificates |
|
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
254 | * |
|
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
255 | * @param gsc The SSL connection handle |
|
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
256 | * |
|
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
257 | * @return The peer certificate chain, in the order of certificate, issuer, |
|
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
258 | * issuer's issuer, etc. NULL if no certificates have been provided, |
|
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
259 | */ |
|
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
260 | GList * purple_ssl_get_peer_certificates(PurpleSslConnection *gsc); |
|
304d2fa12f6a
- purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18449
diff
changeset
|
261 | |
| 6703 | 262 | /*@}*/ |
| 263 | ||
| 264 | /**************************************************************************/ | |
| 265 | /** @name Subsystem API */ | |
| 266 | /**************************************************************************/ | |
| 267 | /*@{*/ | |
| 268 | ||
| 269 | /** | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
270 | * Sets the current SSL operations structure. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
271 | * |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
272 | * @param ops The SSL operations structure to assign. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
273 | */ |
| 15884 | 274 | void purple_ssl_set_ops(PurpleSslOps *ops); |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
275 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
276 | /** |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
277 | * Returns the current SSL operations structure. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
278 | * |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
279 | * @return The SSL operations structure. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
280 | */ |
| 15884 | 281 | PurpleSslOps *purple_ssl_get_ops(void); |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
282 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
283 | /** |
| 6703 | 284 | * Initializes the SSL subsystem. |
| 285 | */ | |
| 15884 | 286 | void purple_ssl_init(void); |
| 6703 | 287 | |
| 288 | /** | |
| 289 | * Uninitializes the SSL subsystem. | |
| 290 | */ | |
| 15884 | 291 | void purple_ssl_uninit(void); |
| 6703 | 292 | |
| 293 | /*@}*/ | |
| 294 | ||
| 295 | #ifdef __cplusplus | |
| 296 | } | |
| 297 | #endif | |
| 298 | ||
| 15884 | 299 | #endif /* _PURPLE_SSLCONN_H_ */ |