Mercurial > pidgin
annotate libpurple/plugins/ssl/ssl-gnutls.c @ 17786:7ed10c051820
Cosmetics
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Tue, 29 May 2007 21:51:53 +0000 |
parents | c5913175c5d2 |
children | 52ba21acc168 |
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 ( |
17786 | 197 _("Certificate name:\n%s\n\nKey fingerprint (SHA1): %s\n\nSerial Number: %s\n\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", |
17786 | 270 "Peer %s provided %d certs\n", |
271 gsc->host, | |
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
|
272 cert_list_size); |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
273 |
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
|
274 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
|
275 { |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
276 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
|
277 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
|
278 gchar * fpr_asc = NULL; |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 gnutls_x509_crt_t cert; |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
283 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
|
284 |
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_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
|
286 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
|
287 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
|
288 |
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 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
|
290 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
|
291 |
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 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
|
293 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
|
294 |
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 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
|
296 "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
|
297 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
|
298 |
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
|
299 tsz=sizeof(tbuf); |
17782
53bd10a83322
- Eliminate some warnings
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17780
diff
changeset
|
300 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
|
301 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
|
302 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
|
303 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
|
304 "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
|
305 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
|
306 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
|
307 |
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 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
|
309 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
|
310 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
|
311 "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
|
312 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 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
|
314 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
|
315 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
|
316 "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
|
317 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
|
318 |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
319 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
|
320 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
|
321 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
|
322 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
|
323 "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
|
324 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 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
|
326 |
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
|
327 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
|
328 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
|
329 } /* 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
|
330 |
17780
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
331 } /* 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
|
332 |
e0eb1eb5b47b
- Added PURPLE_SSL_PEER_AUTH_FAILED to show that an SSL connection was
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17766
diff
changeset
|
333 /* Ask for cert verification */ |
17784
c5913175c5d2
- Fixed the lack of callbackness
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17782
diff
changeset
|
334 ssl_gnutls_authcheck_ask(gsc); |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 static void |
15822 | 341 ssl_gnutls_connect(PurpleSslConnection *gsc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 { |
15822 | 343 PurpleSslGnutlsData *gnutls_data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 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
|
345 |
15822 | 346 gnutls_data = g_new0(PurpleSslGnutlsData, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 gsc->private_data = gnutls_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 gnutls_init(&gnutls_data->session, GNUTLS_CLIENT); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 gnutls_set_default_priority(gnutls_data->session); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 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
|
353 cert_type_priority); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 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
|
356 xcred); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 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
|
359 |
15822 | 360 gnutls_data->handshake_handler = purple_input_add(gsc->fd, |
361 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
|
362 |
17252
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
363 /* 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
|
364 immediately calling it? |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
365 |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
366 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
|
367 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
|
368 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
|
369 the callback. |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
370 |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
371 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
|
372 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
|
373 accomplish this. |
a2edef5eb1b1
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16665
diff
changeset
|
374 */ |
15822 | 375 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
|
376 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 static void |
15822 | 379 ssl_gnutls_close(PurpleSslConnection *gsc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 { |
15822 | 381 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
|
382 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 if(!gnutls_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 if(gnutls_data->handshake_handler) |
15822 | 387 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
|
388 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 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
|
390 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 gnutls_deinit(gnutls_data->session); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 g_free(gnutls_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 gsc->private_data = NULL; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 static size_t |
15822 | 398 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
|
399 { |
15822 | 400 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
|
401 ssize_t s; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 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
|
404 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 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
|
406 s = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 errno = EAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 } else if(s < 0) { |
15822 | 409 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
|
410 gnutls_strerror(s)); |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
411 s = -1; |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
412 /* |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
413 * 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
|
414 * 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
|
415 * 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
|
416 * that returns the error message. |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
417 */ |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
418 errno = EIO; |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 return s; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 static size_t |
15822 | 425 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
|
426 { |
15822 | 427 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
|
428 ssize_t s = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 /* XXX: when will gnutls_data be NULL? */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 if(gnutls_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 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
|
433 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 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
|
435 s = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 errno = EAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 } else if(s < 0) { |
15822 | 438 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
|
439 gnutls_strerror(s)); |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
440 s = -1; |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
441 /* |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
442 * 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
|
443 * 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
|
444 * 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
|
445 * that returns the error message. |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
446 */ |
eed84b59c252
There were a few problems here
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
447 errno = EIO; |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 return s; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 |
15822 | 453 static PurpleSslOps ssl_ops = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 ssl_gnutls_init, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 ssl_gnutls_uninit, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 ssl_gnutls_connect, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 ssl_gnutls_close, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 ssl_gnutls_read, |
16665
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
460 ssl_gnutls_write, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
461 |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
462 /* padding */ |
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, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
466 NULL |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 #endif /* HAVE_GNUTLS */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 static gboolean |
15822 | 472 plugin_load(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 #ifdef HAVE_GNUTLS |
15822 | 475 if(!purple_ssl_get_ops()) { |
476 purple_ssl_set_ops(&ssl_ops); | |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 /* 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
|
480 ssl_gnutls_init_gnutls(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 #endif |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 static gboolean |
15822 | 489 plugin_unload(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 #ifdef HAVE_GNUTLS |
15822 | 492 if(purple_ssl_get_ops() == &ssl_ops) { |
493 purple_ssl_set_ops(NULL); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 |
15822 | 500 static PurplePluginInfo info = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 { |
15822 | 502 PURPLE_PLUGIN_MAGIC, |
503 PURPLE_MAJOR_VERSION, | |
504 PURPLE_MINOR_VERSION, | |
505 PURPLE_PLUGIN_STANDARD, /**< type */ | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 NULL, /**< ui_requirement */ |
15822 | 507 PURPLE_PLUGIN_FLAG_INVISIBLE, /**< flags */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
508 NULL, /**< dependencies */ |
15822 | 509 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 SSL_GNUTLS_PLUGIN_ID, /**< id */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 N_("GNUTLS"), /**< name */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 VERSION, /**< version */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 /** summary */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 N_("Provides SSL support through GNUTLS."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 /** description */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
517 N_("Provides SSL support through GNUTLS."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 "Christian Hammond <chipx86@gnupdate.org>", |
15822 | 519 PURPLE_WEBSITE, /**< homepage */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 plugin_load, /**< load */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 plugin_unload, /**< unload */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 NULL, /**< destroy */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 NULL, /**< ui_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 NULL, /**< extra_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 NULL, /**< prefs_info */ |
16665
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
528 NULL, /**< actions */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
529 |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
530 /* padding */ |
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, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
534 NULL |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 static void |
15822 | 538 init_plugin(PurplePlugin *plugin) |
15373
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 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 |
15822 | 542 PURPLE_INIT_PLUGIN(ssl_gnutls, init_plugin, info) |