Mercurial > pidgin
annotate libpurple/plugins/ssl/ssl-gnutls.c @ 17787:52ba21acc168
disapproval of revision 'b0f6005b1330af13bce0bcb189a2c887036b5ea3'
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Thu, 31 May 2007 00:37:10 +0000 |
parents | 7ed10c051820 |
children | b610b8e0c850 |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file ssl-gnutls.c GNUTLS SSL plugin. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
15822 | 4 * purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 #include "plugin.h" |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
25 #include "request.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "sslconn.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "version.h" |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
28 #include "util.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #define SSL_GNUTLS_PLUGIN_ID "ssl-gnutls" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #ifdef HAVE_GNUTLS |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #include <gnutls/gnutls.h> |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
35 #include <gnutls/x509.h> |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 typedef struct |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 gnutls_session session; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 guint handshake_handler; |
15822 | 41 } PurpleSslGnutlsData; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 |
15822 | 43 #define PURPLE_SSL_GNUTLS_DATA(gsc) ((PurpleSslGnutlsData *)gsc->private_data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 static gnutls_certificate_client_credentials xcred; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 ssl_gnutls_init_gnutls(void) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 gnutls_global_init(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 gnutls_certificate_allocate_credentials(&xcred); |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
53 /*gnutls_certificate_set_x509_trust_file(xcred, "ca.pem", |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
54 GNUTLS_X509_FMT_PEM);*/ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 ssl_gnutls_init(void) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 ssl_gnutls_uninit(void) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 gnutls_global_deinit(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 gnutls_certificate_free_credentials(xcred); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
71 /** Callback from the dialog in ssl_gnutls_authcheck_ask */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
72 static void ssl_gnutls_authcheck_cb(PurpleSslConnection * gsc, gint choice) |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
73 { |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
74 if (NULL == gsc) |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
75 { |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
76 purple_debug_error("gnutls","Inappropriate NULL argument at %s:%d\n", |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
77 __FILE__, (int) __LINE__); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
78 return; |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
79 } |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
80 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
81 switch(choice) |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
82 { |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
83 case 1: /* "Accept" */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
84 /* TODO: Shoud PURPLE_INPUT_READ be hardcoded? */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
85 gsc->connect_cb(gsc->connect_cb_data, gsc, PURPLE_INPUT_READ); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
86 break; |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
87 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
88 default: /* "Cancel" or otherwise...? */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
89 purple_debug_info("gnutls", |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
90 "User rejected certificate from %s\n", |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
91 gsc->host); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
92 if(gsc->error_cb != NULL) |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
93 gsc->error_cb(gsc, PURPLE_SSL_PEER_AUTH_FAILED, |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
94 gsc->connect_cb_data); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
95 purple_ssl_close(gsc); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
96 } |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
97 } |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
98 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
99 /** Pop up a dialog asking for verification of the given certificate */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
100 static void ssl_gnutls_authcheck_ask(PurpleSslConnection * gsc) |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
101 { |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
102 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
103 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
104 const gnutls_datum_t *cert_list; |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
105 unsigned int cert_list_size = 0; |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
106 gnutls_session_t session=gnutls_data->session; |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
107 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
108 cert_list = |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
109 gnutls_certificate_get_peers(session, &cert_list_size); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
110 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
111 if (0 == cert_list_size || NULL == cert_list) |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
112 { |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
113 /* Peer provided no certificates at all. |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
114 TODO: We should write a witty message here. |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
115 */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
116 gchar * primary = g_strdup_printf |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
117 ( |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
118 _("Peer %s provided no certificates.\n Connect anyway?"), |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
119 gsc->host |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
120 ); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
121 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
122 purple_request_accept_cancel |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
123 (gsc, |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
124 _("SSL Authorization Request"), |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
125 primary, |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
126 _("The server you are connecting to presented no certificates identifying itself. You have no assurance that you are not connecting to an imposter. Connect anyway?"), |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
127 2, /* Default action is "Cancel" */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
128 NULL, NULL, /* There is no way to extract account data from |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
129 a connection handle, it seems. */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
130 NULL, /* Same goes for the conversation data */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
131 gsc, /* Pass connection ptr to callback */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
132 ssl_gnutls_authcheck_cb, /* Accept */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
133 ssl_gnutls_authcheck_cb /* Cancel */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
134 ); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
135 g_free(primary); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
136 } |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
137 else |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
138 { |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
139 /* Grab the first certificate and display some data about it */ |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
140 guchar fpr_bin[256]; /* Raw binary key fingerprint */ |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
141 gsize fpr_bin_sz = sizeof(fpr_bin); /* Size of above (used later) */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
142 gchar * fpr_asc = NULL; /* ASCII representation of key fingerprint */ |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
143 guchar ser_bin[256]; /* Certificate Serial Number field */ |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
144 gsize ser_bin_sz = sizeof(ser_bin); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
145 gchar * ser_asc = NULL; |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
146 gchar dn[1024]; /* Certificate Name field */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
147 gsize dn_sz = sizeof(dn); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
148 /* TODO: Analyze certificate time/date stuff */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
149 gboolean CERT_OK = TRUE; /* Is the certificate "good"? */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
150 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
151 gnutls_x509_crt_t cert; /* Certificate data itself */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
152 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
153 /* Suck the certificate data into the structure */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
154 gnutls_x509_crt_init(&cert); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
155 gnutls_x509_crt_import (cert, &cert_list[0], |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
156 GNUTLS_X509_FMT_DER); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
157 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
158 /* Read key fingerprint */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
159 gnutls_x509_crt_get_fingerprint(cert, GNUTLS_MAC_SHA, |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
160 fpr_bin, &fpr_bin_sz); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
161 fpr_asc = purple_base16_encode_chunked(fpr_bin,fpr_bin_sz); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
162 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
163 /* Read serial number */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
164 gnutls_x509_crt_get_serial(cert, ser_bin, &ser_bin_sz); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
165 ser_asc = purple_base16_encode_chunked(ser_bin,ser_bin_sz); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
166 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
167 /* Read the certificate DN field */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
168 gnutls_x509_crt_get_dn(cert, dn, &dn_sz); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
169 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
170 /* TODO: Certificate checking here */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
171 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
172 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
173 /* Build the dialog */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
174 { |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
175 gchar * primary = NULL; |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
176 gchar * secondary = NULL; |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
177 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
178 if ( CERT_OK == TRUE ) |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
179 { |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
180 primary = g_strdup_printf |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
181 ( |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
182 _("Certificate from %s is valid. Accept?"), |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
183 gsc->host |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
184 ); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
185 } |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
186 else |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
187 { |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
188 primary = g_strdup_printf |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
189 ( |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
190 _("Certificate from %s not valid! Accept anyway?"), |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
191 gsc->host |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
192 ); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
193 } |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
194 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
195 secondary = g_strdup_printf |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
196 ( |
17787
52ba21acc168
disapproval of revision 'b0f6005b1330af13bce0bcb189a2c887036b5ea3'
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17786
diff
changeset
|
197 _("Certificate name: %s\nKey fingerprint (SHA1):%s\nSerial Number:%s\nTODO: Expiration dates, etc.\n"), |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
198 dn, fpr_asc, ser_asc |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
199 ); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
200 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
201 purple_request_accept_cancel |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
202 (gsc, |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
203 _("SSL Authorization Request"), |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
204 primary, |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
205 secondary, |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
206 (CERT_OK == TRUE ? 1:2), /* Default action depends on certificate |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
207 status. */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
208 NULL, NULL, /* There is no way to extract account data from |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
209 a connection handle, it seems. */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
210 NULL, /* Same goes for the conversation data */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
211 gsc, /* Pass connection ptr to callback */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
212 ssl_gnutls_authcheck_cb, /* Accept */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
213 ssl_gnutls_authcheck_cb /* Cancel */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
214 ); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
215 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
216 g_free(primary); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
217 g_free(secondary); |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
218 } /* End dialog construction */ |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
219 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
220 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
221 /* Cleanup! */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
222 g_free(fpr_asc); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
223 g_free(ser_asc); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
224 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
225 gnutls_x509_crt_deinit(cert); |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
226 } /* if (0 == ... */ |
17784
c5913175c5d2
- Fixed the lack of callbackness
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17782
diff
changeset
|
227 |
c5913175c5d2
- Fixed the lack of callbackness
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17782
diff
changeset
|
228 purple_debug_info("gnutls","Requested user verification for certificate from %s\n", gsc->host); |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
229 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 static void ssl_gnutls_handshake_cb(gpointer data, gint source, |
15822 | 232 PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 { |
15822 | 234 PurpleSslConnection *gsc = data; |
235 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 ssize_t ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 |
15822 | 238 purple_debug_info("gnutls", "Handshaking\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 ret = gnutls_handshake(gnutls_data->session); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 if(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 |
15822 | 244 purple_input_remove(gnutls_data->handshake_handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 gnutls_data->handshake_handler = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 if(ret != 0) { |
15822 | 248 purple_debug_error("gnutls", "Handshake failed. Error %s\n", |
15784
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
249 gnutls_strerror(ret)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 if(gsc->error_cb != NULL) |
15822 | 252 gsc->error_cb(gsc, PURPLE_SSL_HANDSHAKE_FAILED, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 gsc->connect_cb_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 |
15822 | 255 purple_ssl_close(gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 } else { |
15822 | 257 purple_debug_info("gnutls", "Handshake complete\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
259 /* Spit some key info to debug */ |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
260 { |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
261 const gnutls_datum_t *cert_list; |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
262 unsigned int cert_list_size = 0; |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
263 gnutls_session_t session=gnutls_data->session; |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
264 int i; |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
265 |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
266 cert_list = |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
267 gnutls_certificate_get_peers(session, &cert_list_size); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
268 |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
269 purple_debug_info("gnutls", |
17787
52ba21acc168
disapproval of revision 'b0f6005b1330af13bce0bcb189a2c887036b5ea3'
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17786
diff
changeset
|
270 "Peer provided %d certs\n", |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
271 cert_list_size); |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
272 |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
273 for (i=0; i<cert_list_size; i++) |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
274 { |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
275 guchar fpr_bin[256]; |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
276 gsize fpr_bin_sz = sizeof(fpr_bin); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
277 gchar * fpr_asc = NULL; |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
278 guchar tbuf[256]; |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
279 gsize tsz=sizeof(tbuf); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
280 gchar * tasc = NULL; |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
281 gnutls_x509_crt_t cert; |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
282 int ret; |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
283 |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
284 gnutls_x509_crt_init(&cert); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
285 gnutls_x509_crt_import (cert, &cert_list[i], |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
286 GNUTLS_X509_FMT_DER); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
287 |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
288 gnutls_x509_crt_get_fingerprint(cert, GNUTLS_MAC_SHA, |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
289 fpr_bin, &fpr_bin_sz); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
290 |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
291 fpr_asc = |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
292 purple_base16_encode_chunked(fpr_bin,fpr_bin_sz); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
293 |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
294 purple_debug_info("gnutls", |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
295 "Lvl %d SHA1 fingerprint: %s\n", |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
296 i, fpr_asc); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
297 |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
298 tsz=sizeof(tbuf); |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
299 gnutls_x509_crt_get_serial(cert,tbuf,&tsz); |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
300 tasc= |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
301 purple_base16_encode_chunked(tbuf, tsz); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
302 purple_debug_info("gnutls", |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
303 "Serial: %s(%d bytes, ret=%d)\n", |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
304 tasc, tsz, ret); |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
305 g_free(tasc); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
306 |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
307 tsz=sizeof(tbuf); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
308 gnutls_x509_crt_get_dn (cert, tbuf, &tsz); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
309 purple_debug_info("gnutls", |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
310 "Cert DN: %s\n", |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
311 tbuf); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
312 tsz=sizeof(tbuf); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
313 gnutls_x509_crt_get_issuer_dn (cert, tbuf, &tsz); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
314 purple_debug_info("gnutls", |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
315 "Cert Issuer DN: %s\n", |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
316 tbuf); |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
317 |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
318 tsz=sizeof(tbuf); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
319 gnutls_x509_crt_get_key_id(cert,0, tbuf, &tsz); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
320 tasc = purple_base16_encode_chunked(tbuf, tsz); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
321 purple_debug_info("gnutls", |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
322 "Key ID: %s\n", |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
323 tasc); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
324 g_free(tasc); |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
325 |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
326 g_free(fpr_asc); fpr_asc = NULL; |
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
327 gnutls_x509_crt_deinit(cert); |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
328 } /* for */ |
17766
fe571cfcf225
- Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17252
diff
changeset
|
329 |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
330 } /* End keydata spitting */ |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
331 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
332 /* Ask for cert verification */ |
17784
c5913175c5d2
- Fixed the lack of callbackness
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17782
diff
changeset
|
333 ssl_gnutls_authcheck_ask(gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 static void |
15822 | 340 ssl_gnutls_connect(PurpleSslConnection *gsc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 { |
15822 | 342 PurpleSslGnutlsData *gnutls_data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 static const int cert_type_priority[2] = { GNUTLS_CRT_X509, 0 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 |
15822 | 345 gnutls_data = g_new0(PurpleSslGnutlsData, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 gsc->private_data = gnutls_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 gnutls_init(&gnutls_data->session, GNUTLS_CLIENT); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 gnutls_set_default_priority(gnutls_data->session); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 gnutls_certificate_type_set_priority(gnutls_data->session, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 cert_type_priority); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 gnutls_credentials_set(gnutls_data->session, GNUTLS_CRD_CERTIFICATE, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 xcred); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 gnutls_transport_set_ptr(gnutls_data->session, GINT_TO_POINTER(gsc->fd)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 |
15822 | 359 gnutls_data->handshake_handler = purple_input_add(gsc->fd, |
360 PURPLE_INPUT_READ, ssl_gnutls_handshake_cb, gsc); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 |
17252
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
362 /* Orborde asks: Why are we configuring a callback, then |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
363 immediately calling it? |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
364 |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
365 Answer: gnutls_handshake (up in handshake_cb) needs to be called |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
366 once in order to get the ball rolling on the SSL connection. |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
367 Once it has done so, only then will the server reply, triggering |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
368 the callback. |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
369 |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
370 Since the logic driving gnutls_handshake is the same with the first |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
371 and subsequent calls, we'll just fire the callback immediately to |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
372 accomplish this. |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
373 */ |
15822 | 374 ssl_gnutls_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 static void |
15822 | 378 ssl_gnutls_close(PurpleSslConnection *gsc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 { |
15822 | 380 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 if(!gnutls_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 if(gnutls_data->handshake_handler) |
15822 | 386 purple_input_remove(gnutls_data->handshake_handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 gnutls_bye(gnutls_data->session, GNUTLS_SHUT_RDWR); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 gnutls_deinit(gnutls_data->session); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 g_free(gnutls_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 gsc->private_data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 static size_t |
15822 | 397 ssl_gnutls_read(PurpleSslConnection *gsc, void *data, size_t len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 { |
15822 | 399 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 ssize_t s; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 s = gnutls_record_recv(gnutls_data->session, data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 if(s == GNUTLS_E_AGAIN || s == GNUTLS_E_INTERRUPTED) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 s = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 errno = EAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 } else if(s < 0) { |
15822 | 408 purple_debug_error("gnutls", "receive failed: %s\n", |
15784
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
409 gnutls_strerror(s)); |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
410 s = -1; |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
411 /* |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
412 * TODO: Set errno to something more appropriate. Or even |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
413 * better: allow ssl plugins to keep track of their |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
414 * own error message, then add a new ssl_ops function |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
415 * that returns the error message. |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
416 */ |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
417 errno = EIO; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 return s; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 static size_t |
15822 | 424 ssl_gnutls_write(PurpleSslConnection *gsc, const void *data, size_t len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 { |
15822 | 426 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 ssize_t s = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 /* XXX: when will gnutls_data be NULL? */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 if(gnutls_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 s = gnutls_record_send(gnutls_data->session, data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 if(s == GNUTLS_E_AGAIN || s == GNUTLS_E_INTERRUPTED) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 s = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 errno = EAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 } else if(s < 0) { |
15822 | 437 purple_debug_error("gnutls", "send failed: %s\n", |
15784
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
438 gnutls_strerror(s)); |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
439 s = -1; |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
440 /* |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
441 * TODO: Set errno to something more appropriate. Or even |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
442 * better: allow ssl plugins to keep track of their |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
443 * own error message, then add a new ssl_ops function |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
444 * that returns the error message. |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
445 */ |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
446 errno = EIO; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 return s; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 |
15822 | 452 static PurpleSslOps ssl_ops = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 ssl_gnutls_init, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 ssl_gnutls_uninit, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 ssl_gnutls_connect, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 ssl_gnutls_close, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 ssl_gnutls_read, |
16665
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
459 ssl_gnutls_write, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
460 |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
461 /* padding */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
462 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
463 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
464 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
465 NULL |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 #endif /* HAVE_GNUTLS */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 static gboolean |
15822 | 471 plugin_load(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 #ifdef HAVE_GNUTLS |
15822 | 474 if(!purple_ssl_get_ops()) { |
475 purple_ssl_set_ops(&ssl_ops); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 /* Init GNUTLS now so others can use it even if sslconn never does */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 ssl_gnutls_init_gnutls(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 static gboolean |
15822 | 488 plugin_unload(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 #ifdef HAVE_GNUTLS |
15822 | 491 if(purple_ssl_get_ops() == &ssl_ops) { |
492 purple_ssl_set_ops(NULL); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 |
15822 | 499 static PurplePluginInfo info = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 { |
15822 | 501 PURPLE_PLUGIN_MAGIC, |
502 PURPLE_MAJOR_VERSION, | |
503 PURPLE_MINOR_VERSION, | |
504 PURPLE_PLUGIN_STANDARD, /**< type */ | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 NULL, /**< ui_requirement */ |
15822 | 506 PURPLE_PLUGIN_FLAG_INVISIBLE, /**< flags */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 NULL, /**< dependencies */ |
15822 | 508 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 SSL_GNUTLS_PLUGIN_ID, /**< id */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 N_("GNUTLS"), /**< name */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 VERSION, /**< version */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 /** summary */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 N_("Provides SSL support through GNUTLS."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 /** description */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 N_("Provides SSL support through GNUTLS."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
517 "Christian Hammond <chipx86@gnupdate.org>", |
15822 | 518 PURPLE_WEBSITE, /**< homepage */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 plugin_load, /**< load */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 plugin_unload, /**< unload */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 NULL, /**< destroy */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 NULL, /**< ui_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 NULL, /**< extra_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 NULL, /**< prefs_info */ |
16665
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
527 NULL, /**< actions */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
528 |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
529 /* padding */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
530 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
531 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
532 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
533 NULL |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 static void |
15822 | 537 init_plugin(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 |
15822 | 541 PURPLE_INIT_PLUGIN(ssl_gnutls, init_plugin, info) |