annotate libpurple/plugins/ssl/ssl-gnutls.c @ 26044:b04508e5cc6c

merge of 'd43b253ca7568a3f07aa77bf397fe4351db73a90' and 'dcc53c9783aecbdde6269c4310ec4b0cf511bd9e'
author Marcus Lundblad <ml@update.uu.se>
date Mon, 12 Jan 2009 19:27:55 +0000
parents e39cafdbe089
children 6eff00e729ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
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
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19649
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
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"
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
24 #include "certificate.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "plugin.h"
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 #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
33 #include <gnutls/x509.h>
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 typedef struct
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 gnutls_session session;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 guint handshake_handler;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
39 } PurpleSslGnutlsData;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
41 #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
42
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 static gnutls_certificate_client_credentials xcred;
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 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 ssl_gnutls_init_gnutls(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 {
17911
91feef6cbede - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17793
diff changeset
48 /* Configure GnuTLS to use glib memory management */
91feef6cbede - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17793
diff changeset
49 /* I expect that this isn't really necessary, but it may prevent
91feef6cbede - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17793
diff changeset
50 some bugs */
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
51 /* TODO: It may be necessary to wrap this allocators for GnuTLS.
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
52 If there are strange bugs, perhaps look here (yes, I am a
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
53 hypocrite) */
17911
91feef6cbede - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17793
diff changeset
54 gnutls_global_set_mem_functions(
23276
b87ce62751a2 I can't think of any reason we would need to use the zero versions of
Mark Doliner <mark@kingant.net>
parents: 21678
diff changeset
55 (gnutls_alloc_function) g_malloc, /* malloc */
b87ce62751a2 I can't think of any reason we would need to use the zero versions of
Mark Doliner <mark@kingant.net>
parents: 21678
diff changeset
56 (gnutls_alloc_function) g_malloc, /* secure malloc */
17911
91feef6cbede - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17793
diff changeset
57 NULL, /* mem_is_secure */
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
58 (gnutls_realloc_function) g_realloc, /* realloc */
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
59 (gnutls_free_function) g_free /* free */
17911
91feef6cbede - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17793
diff changeset
60 );
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
61
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 gnutls_global_init();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 gnutls_certificate_allocate_credentials(&xcred);
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
65
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
66 /* TODO: I can likely remove this */
17781
3ce170204ef0 disapproval of revision '38e35430b0f7a8b7d764fca702732e7f1c652d02'
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17780
diff changeset
67 gnutls_certificate_set_x509_trust_file(xcred, "ca.pem",
3ce170204ef0 disapproval of revision '38e35430b0f7a8b7d764fca702732e7f1c652d02'
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17780
diff changeset
68 GNUTLS_X509_FMT_PEM);
15373
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 static gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 ssl_gnutls_init(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 {
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
74 return TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 ssl_gnutls_uninit(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 gnutls_global_deinit();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 gnutls_certificate_free_credentials(xcred);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84
18955
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
85 static void
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
86 ssl_gnutls_verified_cb(PurpleCertificateVerificationStatus st,
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
87 gpointer userdata)
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
88 {
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
89 PurpleSslConnection *gsc = (PurpleSslConnection *) userdata;
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
90
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
91 if (st == PURPLE_CERTIFICATE_VALID) {
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
92 /* Certificate valid? Good! Do the connection! */
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
93 gsc->connect_cb(gsc->connect_cb_data, gsc, PURPLE_INPUT_READ);
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
94 } else {
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
95 /* Otherwise, signal an error */
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
96 if(gsc->error_cb != NULL)
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
97 gsc->error_cb(gsc, PURPLE_SSL_CERTIFICATE_INVALID,
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
98 gsc->connect_cb_data);
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
99 purple_ssl_close(gsc);
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
100 }
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
101 }
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
102
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
103
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 static void ssl_gnutls_handshake_cb(gpointer data, gint source,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
106 PurpleInputCondition cond)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
108 PurpleSslConnection *gsc = data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
109 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
110 ssize_t ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111
20255
07c103ac3795 applied changes from 5252885d793a4d288d92856d511d721bf5bb87ef
Richard Laager <rlaager@wiktel.com>
parents: 19681
diff changeset
112 /*purple_debug_info("gnutls", "Handshaking with %s\n", gsc->host);*/
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 ret = gnutls_handshake(gnutls_data->session);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 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
116 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
118 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
119 gnutls_data->handshake_handler = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 if(ret != 0) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
122 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
123 gnutls_strerror(ret));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 if(gsc->error_cb != NULL)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
126 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
127 gsc->connect_cb_data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
129 purple_ssl_close(gsc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 } else {
18938
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
131 /* Now we are cooking with gas! */
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
132 PurpleSslOps *ops = purple_ssl_get_ops();
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
133 GList * peers = ops->get_peer_certificates(gsc);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
134
18938
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
135 PurpleCertificateScheme *x509 =
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
136 purple_certificate_find_scheme("x509");
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
137
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
138 GList * l;
19549
5f4100c7dd00 Fix compiler warnings about having a variable declaration after some
Mark Doliner <mark@kingant.net>
parents: 19498
diff changeset
139
5f4100c7dd00 Fix compiler warnings about having a variable declaration after some
Mark Doliner <mark@kingant.net>
parents: 19498
diff changeset
140 /* TODO: Remove all this debugging babble */
5f4100c7dd00 Fix compiler warnings about having a variable declaration after some
Mark Doliner <mark@kingant.net>
parents: 19498
diff changeset
141 purple_debug_info("gnutls", "Handshake complete\n");
5f4100c7dd00 Fix compiler warnings about having a variable declaration after some
Mark Doliner <mark@kingant.net>
parents: 19498
diff changeset
142
18938
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
143 for (l=peers; l; l = l->next) {
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
144 PurpleCertificate *crt = l->data;
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
145 GByteArray *z =
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
146 x509->get_fingerprint_sha1(crt);
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
147 gchar * fpr =
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
148 purple_base16_encode_chunked(z->data,
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
149 z->len);
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
150
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
151 purple_debug_info("gnutls/x509",
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
152 "Key print: %s\n",
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
153 fpr);
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
154
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
155 /* Kill the cert! */
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
156 x509->destroy_certificate(crt);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
157
18938
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
158 g_free(fpr);
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
159 g_byte_array_free(z, TRUE);
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
160 }
f2ddc4b10d72 - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18935
diff changeset
161 g_list_free(peers);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
162
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
163 {
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
164 const gnutls_datum *cert_list;
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
165 unsigned int cert_list_size = 0;
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
166 gnutls_session session=gnutls_data->session;
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
167 int i;
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
168
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
169 cert_list =
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
170 gnutls_certificate_get_peers(session, &cert_list_size);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
171
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
172 purple_debug_info("gnutls",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
173 "Peer provided %d certs\n",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
174 cert_list_size);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
175 for (i=0; i<cert_list_size; i++)
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
176 {
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
177 gchar fpr_bin[256];
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
178 gsize fpr_bin_sz = sizeof(fpr_bin);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
179 gchar * fpr_asc = NULL;
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
180 gchar tbuf[256];
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
181 gsize tsz=sizeof(tbuf);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
182 gchar * tasc = NULL;
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
183 gnutls_x509_crt cert;
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
184
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
185 gnutls_x509_crt_init(&cert);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
186 gnutls_x509_crt_import (cert, &cert_list[i],
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
187 GNUTLS_X509_FMT_DER);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
188
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
189 gnutls_x509_crt_get_fingerprint(cert, GNUTLS_MAC_SHA,
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
190 fpr_bin, &fpr_bin_sz);
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
191
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
192 fpr_asc =
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
193 purple_base16_encode_chunked((const guchar *)fpr_bin, fpr_bin_sz);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
194
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
195 purple_debug_info("gnutls",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
196 "Lvl %d SHA1 fingerprint: %s\n",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
197 i, fpr_asc);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
198
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
199 tsz=sizeof(tbuf);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
200 gnutls_x509_crt_get_serial(cert,tbuf,&tsz);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
201 tasc=purple_base16_encode_chunked((const guchar *)tbuf, tsz);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
202 purple_debug_info("gnutls",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
203 "Serial: %s\n",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
204 tasc);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
205 g_free(tasc);
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
206
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
207 tsz=sizeof(tbuf);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
208 gnutls_x509_crt_get_dn (cert, tbuf, &tsz);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
209 purple_debug_info("gnutls",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
210 "Cert DN: %s\n",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
211 tbuf);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
212 tsz=sizeof(tbuf);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
213 gnutls_x509_crt_get_issuer_dn (cert, tbuf, &tsz);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
214 purple_debug_info("gnutls",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
215 "Cert Issuer DN: %s\n",
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
216 tbuf);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
217
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
218 g_free(fpr_asc);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
219 fpr_asc = NULL;
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
220 gnutls_x509_crt_deinit(cert);
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
221 }
17781
3ce170204ef0 disapproval of revision '38e35430b0f7a8b7d764fca702732e7f1c652d02'
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17780
diff changeset
222 }
18955
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
223
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
224 /* TODO: The following logic should really be in libpurple */
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
225 /* If a Verifier was given, hand control over to it */
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
226 if (gsc->verifier) {
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
227 GList *peers;
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
228 /* First, get the peer cert chain */
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
229 peers = purple_ssl_get_peer_certificates(gsc);
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
230
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
231 /* Now kick off the verification process */
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
232 purple_certificate_verify(gsc->verifier,
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
233 gsc->host,
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
234 peers,
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
235 ssl_gnutls_verified_cb,
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
236 gsc);
19021
fcca10d0ac7d - purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
237
fcca10d0ac7d - purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
238 purple_certificate_destroy_list(peers);
18955
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
239 } else {
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
240 /* Otherwise, just call the "connection complete"
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
241 callback */
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
242 gsc->connect_cb(gsc->connect_cb_data, gsc, cond);
f393eddab077 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18938
diff changeset
243 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
250 ssl_gnutls_connect(PurpleSslConnection *gsc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
252 PurpleSslGnutlsData *gnutls_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 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
254
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
255 gnutls_data = g_new0(PurpleSslGnutlsData, 1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 gsc->private_data = gnutls_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 gnutls_init(&gnutls_data->session, GNUTLS_CLIENT);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 gnutls_set_default_priority(gnutls_data->session);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 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
262 cert_type_priority);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 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
265 xcred);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 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
268
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
269 gnutls_data->handshake_handler = purple_input_add(gsc->fd,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
270 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
271
20255
07c103ac3795 applied changes from 5252885d793a4d288d92856d511d721bf5bb87ef
Richard Laager <rlaager@wiktel.com>
parents: 19681
diff changeset
272 purple_debug_info("gnutls", "Starting handshake with %s\n", gsc->host);
07c103ac3795 applied changes from 5252885d793a4d288d92856d511d721bf5bb87ef
Richard Laager <rlaager@wiktel.com>
parents: 19681
diff changeset
273
17252
a2edef5eb1b1 - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16665
diff changeset
274 /* 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
275 immediately calling it?
a2edef5eb1b1 - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16665
diff changeset
276
a2edef5eb1b1 - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16665
diff changeset
277 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
278 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
279 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
280 the callback.
a2edef5eb1b1 - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16665
diff changeset
281
a2edef5eb1b1 - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16665
diff changeset
282 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
283 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
284 accomplish this.
a2edef5eb1b1 - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16665
diff changeset
285 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
286 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
287 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
290 ssl_gnutls_close(PurpleSslConnection *gsc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
292 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
293
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 if(!gnutls_data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 if(gnutls_data->handshake_handler)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
298 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
299
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 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
301
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 gnutls_deinit(gnutls_data->session);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 g_free(gnutls_data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 gsc->private_data = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 static size_t
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
309 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
310 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
311 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
312 ssize_t s;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 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
315
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 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
317 s = -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 errno = EAGAIN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 } else if(s < 0) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
320 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
321 gnutls_strerror(s));
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
322 s = -1;
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
323 /*
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
324 * 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
325 * 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
326 * 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
327 * that returns the error message.
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
328 */
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
329 errno = EIO;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 return s;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 }
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 static size_t
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
336 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
337 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
338 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
339 ssize_t s = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 /* XXX: when will gnutls_data be NULL? */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 if(gnutls_data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 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
344
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 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
346 s = -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 errno = EAGAIN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 } else if(s < 0) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
349 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
350 gnutls_strerror(s));
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
351 s = -1;
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
352 /*
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
353 * 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
354 * 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
355 * 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
356 * that returns the error message.
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
357 */
eed84b59c252 There were a few problems here
Mark Doliner <mark@kingant.net>
parents: 15373
diff changeset
358 errno = EIO;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 return s;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363
19491
4f472eef762c - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19218
diff changeset
364 /* Forward declarations are fun! */
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
365 static PurpleCertificate *
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
366 x509_import_from_datum(const gnutls_datum dt, gnutls_x509_crt_fmt mode);
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
367
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
368 static GList *
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
369 ssl_gnutls_get_peer_certificates(PurpleSslConnection * gsc)
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
370 {
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
371 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc);
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
372
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
373 /* List of Certificate instances to return */
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
374 GList * peer_certs = NULL;
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
375
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
376 /* List of raw certificates as given by GnuTLS */
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
377 const gnutls_datum *cert_list;
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
378 unsigned int cert_list_size = 0;
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
379
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
380 unsigned int i;
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
381
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
382 /* This should never, ever happen. */
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
383 g_return_val_if_fail( gnutls_certificate_type_get (gnutls_data->session) == GNUTLS_CRT_X509, NULL);
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
384
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
385 /* Get the certificate list from GnuTLS */
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
386 /* TODO: I am _pretty sure_ this doesn't block or do other exciting things */
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
387 cert_list = gnutls_certificate_get_peers(gnutls_data->session,
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
388 &cert_list_size);
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
389
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
390 /* Convert each certificate to a Certificate and append it to the list */
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
391 for (i = 0; i < cert_list_size; i++) {
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
392 PurpleCertificate * newcrt = x509_import_from_datum(cert_list[i],
18186
80c909c5bb7a - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17914
diff changeset
393 GNUTLS_X509_FMT_DER);
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
394 /* Append is somewhat inefficient on linked lists, but is easy
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
395 to read. If someone complains, I'll change it.
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
396 TODO: Is anyone complaining? (Maybe elb?) */
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
397 peer_certs = g_list_append(peer_certs, newcrt);
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
398 }
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
399
19491
4f472eef762c - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19218
diff changeset
400 /* cert_list doesn't need free()-ing */
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
401
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
402 return peer_certs;
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
403 }
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
404
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
405 /************************************************************************/
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
406 /* X.509 functionality */
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
407 /************************************************************************/
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
408 const gchar * SCHEME_NAME = "x509";
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
409
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
410 static PurpleCertificateScheme x509_gnutls;
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
411
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
412 /** Refcounted GnuTLS certificate data instance */
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
413 typedef struct {
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
414 gint refcount;
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
415 gnutls_x509_crt crt;
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
416 } x509_crtdata_t;
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
417
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
418 /** Helper functions for reference counting */
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
419 static x509_crtdata_t *
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
420 x509_crtdata_addref(x509_crtdata_t *cd)
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
421 {
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
422 (cd->refcount)++;
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
423 return cd;
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
424 }
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
425
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
426 static void
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
427 x509_crtdata_delref(x509_crtdata_t *cd)
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
428 {
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
429 (cd->refcount)--;
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
430
19552
c35c3c3fc4cf refcount of 0 is normal
Mark Doliner <mark@kingant.net>
parents: 19551
diff changeset
431 if (cd->refcount < 0)
19551
ce3dec442fec Replace a call to g_assert() with a logging statement
Mark Doliner <mark@kingant.net>
parents: 19550
diff changeset
432 g_critical("Refcount of x509_crtdata_t is %d, which is less "
ce3dec442fec Replace a call to g_assert() with a logging statement
Mark Doliner <mark@kingant.net>
parents: 19550
diff changeset
433 "than zero!\n", cd->refcount);
ce3dec442fec Replace a call to g_assert() with a logging statement
Mark Doliner <mark@kingant.net>
parents: 19550
diff changeset
434
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
435 /* If the refcount reaches zero, kill the structure */
19551
ce3dec442fec Replace a call to g_assert() with a logging statement
Mark Doliner <mark@kingant.net>
parents: 19550
diff changeset
436 if (cd->refcount <= 0) {
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
437 /* Kill the internal data */
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
438 gnutls_x509_crt_deinit( cd->crt );
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
439 /* And kill the struct */
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
440 g_free( cd );
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
441 }
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
442 }
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
443
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
444 /** Helper macro to retrieve the GnuTLS crt_t from a PurpleCertificate */
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
445 #define X509_GET_GNUTLS_DATA(pcrt) ( ((x509_crtdata_t *) (pcrt->data))->crt)
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
446
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
447 /** Transforms a gnutls_datum containing an X.509 certificate into a Certificate instance under the x509_gnutls scheme
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
448 *
18186
80c909c5bb7a - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17914
diff changeset
449 * @param dt Datum to transform
80c909c5bb7a - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17914
diff changeset
450 * @param mode GnuTLS certificate format specifier (GNUTLS_X509_FMT_PEM for
80c909c5bb7a - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17914
diff changeset
451 * reading from files, and GNUTLS_X509_FMT_DER for converting
80c909c5bb7a - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17914
diff changeset
452 * "over the wire" certs for SSL)
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
453 *
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
454 * @return A newly allocated Certificate structure of the x509_gnutls scheme
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
455 */
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
456 static PurpleCertificate *
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
457 x509_import_from_datum(const gnutls_datum dt, gnutls_x509_crt_fmt mode)
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
458 {
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
459 /* Internal certificate data structure */
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
460 x509_crtdata_t *certdat;
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
461 /* New certificate to return */
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
462 PurpleCertificate * crt;
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
463
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
464 /* Allocate and prepare the internal certificate data */
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
465 certdat = g_new0(x509_crtdata_t, 1);
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
466 gnutls_x509_crt_init(&(certdat->crt));
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
467 certdat->refcount = 0;
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
468
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
469 /* Perform the actual certificate parse */
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
470 /* Yes, certdat->crt should be passed as-is */
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
471 gnutls_x509_crt_import(certdat->crt, &dt, mode);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
472
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
473 /* Allocate the certificate and load it with data */
18961
fa138dbacff5 - More g_new0 instead of g_new
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18955
diff changeset
474 crt = g_new0(PurpleCertificate, 1);
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
475 crt->scheme = &x509_gnutls;
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
476 crt->data = x509_crtdata_addref(certdat);
17914
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
477
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
478 return crt;
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
479 }
2f119e2a1b33 - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17913
diff changeset
480
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
481 /** Imports a PEM-formatted X.509 certificate from the specified file.
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
482 * @param filename Filename to import from. Format is PEM
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
483 *
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
484 * @return A newly allocated Certificate structure of the x509_gnutls scheme
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
485 */
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
486 static PurpleCertificate *
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
487 x509_import_from_file(const gchar * filename)
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
488 {
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
489 PurpleCertificate *crt; /* Certificate being constructed */
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
490 gchar *buf; /* Used to load the raw file data */
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
491 gsize buf_sz; /* Size of the above */
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
492 gnutls_datum dt; /* Struct to pass down to GnuTLS */
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
493
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
494 purple_debug_info("gnutls",
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
495 "Attempting to load X.509 certificate from %s\n",
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
496 filename);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
497
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
498 /* Next, we'll simply yank the entire contents of the file
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
499 into memory */
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
500 /* TODO: Should I worry about very large files here? */
19491
4f472eef762c - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19218
diff changeset
501 g_return_val_if_fail(
4f472eef762c - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19218
diff changeset
502 g_file_get_contents(filename,
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
503 &buf,
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
504 &buf_sz,
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
505 NULL /* No error checking for now */
19491
4f472eef762c - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19218
diff changeset
506 ),
4f472eef762c - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19218
diff changeset
507 NULL);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
508
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
509 /* Load the datum struct */
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
510 dt.data = (unsigned char *) buf;
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
511 dt.size = buf_sz;
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
512
21678
a890a1574703 Boo for C99 in the core
Ethan Blanton <elb@pidgin.im>
parents: 21030
diff changeset
513 /* Perform the conversion; files should be in PEM format */
a890a1574703 Boo for C99 in the core
Ethan Blanton <elb@pidgin.im>
parents: 21030
diff changeset
514 crt = x509_import_from_datum(dt, GNUTLS_X509_FMT_PEM);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
515
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
516 /* Cleanup */
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
517 g_free(buf);
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
518
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
519 return crt;
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
520 }
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
521
18977
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
522 /**
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
523 * Exports a PEM-formatted X.509 certificate to the specified file.
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
524 * @param filename Filename to export to. Format will be PEM
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
525 * @param crt Certificate to export
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
526 *
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
527 * @return TRUE if success, otherwise FALSE
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
528 */
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
529 static gboolean
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
530 x509_export_certificate(const gchar *filename, PurpleCertificate *crt)
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
531 {
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
532 gnutls_x509_crt crt_dat; /* GnuTLS cert struct */
18977
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
533 int ret;
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
534 gchar * out_buf; /* Data to output */
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
535 size_t out_size; /* Output size */
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
536 gboolean success = FALSE;
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
537
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
538 /* Paranoia paranoia paranoia! */
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
539 g_return_val_if_fail(filename, FALSE);
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
540 g_return_val_if_fail(crt, FALSE);
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
541 g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE);
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
542 g_return_val_if_fail(crt->data, FALSE);
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
543
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
544 crt_dat = X509_GET_GNUTLS_DATA(crt);
18977
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
545
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
546 /* Obtain the output size required */
19004
d4065b26dcac - Fix intermittent crash due to uninitialized variable
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19003
diff changeset
547 out_size = 0;
18977
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
548 ret = gnutls_x509_crt_export(crt_dat, GNUTLS_X509_FMT_PEM,
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
549 NULL, /* Provide no buffer yet */
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
550 &out_size /* Put size here */
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
551 );
19002
daeca1b9ebdb - Fix an incorrect assertion in GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18977
diff changeset
552 g_return_val_if_fail(ret == GNUTLS_E_SHORT_MEMORY_BUFFER, FALSE);
18977
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
553
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
554 /* Now allocate a buffer and *really* export it */
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
555 out_buf = g_new0(gchar, out_size);
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
556 ret = gnutls_x509_crt_export(crt_dat, GNUTLS_X509_FMT_PEM,
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
557 out_buf, /* Export to our new buffer */
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
558 &out_size /* Put size here */
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
559 );
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
560 if (ret != 0) {
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
561 purple_debug_error("gnutls/x509",
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
562 "Failed to export cert to buffer with code %d\n",
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
563 ret);
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
564 g_free(out_buf);
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
565 return FALSE;
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
566 }
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
567
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
568 /* Write it out to an actual file */
19498
7589b218f89a - Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19494
diff changeset
569 success = purple_util_write_data_to_file_absolute(filename,
7589b218f89a - Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19494
diff changeset
570 out_buf, out_size);
18977
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
571
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
572 g_free(out_buf);
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
573 g_return_val_if_fail(success, FALSE);
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
574 return success;
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
575 }
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
576
19019
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
577 static PurpleCertificate *
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
578 x509_copy_certificate(PurpleCertificate *crt)
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
579 {
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
580 x509_crtdata_t *crtdat;
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
581 PurpleCertificate *newcrt;
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
582
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
583 g_return_val_if_fail(crt, NULL);
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
584 g_return_val_if_fail(crt->scheme == &x509_gnutls, NULL);
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
585
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
586 crtdat = (x509_crtdata_t *) crt->data;
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
587
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
588 newcrt = g_new0(PurpleCertificate, 1);
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
589 newcrt->scheme = &x509_gnutls;
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
590 newcrt->data = x509_crtdata_addref(crtdat);
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
591
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
592 return newcrt;
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
593 }
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
594 /** Frees a Certificate
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
595 *
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
596 * Destroys a Certificate's internal data structures and frees the pointer
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
597 * given.
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
598 * @param crt Certificate instance to be destroyed. It WILL NOT be destroyed
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
599 * if it is not of the correct CertificateScheme. Can be NULL
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
600 *
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
601 */
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
602 static void
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
603 x509_destroy_certificate(PurpleCertificate * crt)
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
604 {
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
605 if (NULL == crt) return;
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
606
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
607 /* Check that the scheme is x509_gnutls */
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
608 if ( crt->scheme != &x509_gnutls ) {
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
609 purple_debug_error("gnutls",
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
610 "destroy_certificate attempted on certificate of wrong scheme (scheme was %s, expected %s)\n",
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
611 crt->scheme->name,
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
612 SCHEME_NAME);
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
613 return;
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
614 }
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
615
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
616 g_return_if_fail(crt->data != NULL);
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
617 g_return_if_fail(crt->scheme != NULL);
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
618
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
619 /* Use the reference counting system to free (or not) the
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
620 underlying data */
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
621 x509_crtdata_delref((x509_crtdata_t *)crt->data);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
622
17913
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
623 /* Kill the structure itself */
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
624 g_free(crt);
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
625 }
55a0b0a42000 - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17911
diff changeset
626
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
627 /** Determines whether one certificate has been issued and signed by another
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
628 *
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
629 * @param crt Certificate to check the signature of
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
630 * @param issuer Issuer's certificate
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
631 *
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
632 * @return TRUE if crt was signed and issued by issuer, otherwise FALSE
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
633 * @TODO Modify this function to return a reason for invalidity?
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
634 */
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
635 static gboolean
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
636 x509_certificate_signed_by(PurpleCertificate * crt,
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
637 PurpleCertificate * issuer)
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
638 {
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
639 gnutls_x509_crt crt_dat;
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
640 gnutls_x509_crt issuer_dat;
19212
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
641 unsigned int verify; /* used to store result from GnuTLS verifier */
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
642 int ret;
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
643
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
644 g_return_val_if_fail(crt, FALSE);
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
645 g_return_val_if_fail(issuer, FALSE);
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
646
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
647 /* Verify that both certs are the correct scheme */
18963
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
648 g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE);
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
649 g_return_val_if_fail(issuer->scheme == &x509_gnutls, FALSE);
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
650
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
651 /* TODO: check for more nullness? */
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
652
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
653 crt_dat = X509_GET_GNUTLS_DATA(crt);
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
654 issuer_dat = X509_GET_GNUTLS_DATA(issuer);
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
655
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
656 /* First, let's check that crt.issuer is actually issuer */
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
657 ret = gnutls_x509_crt_check_issuer(crt_dat, issuer_dat);
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
658 if (ret <= 0) {
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
659
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
660 if (ret < 0) {
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
661 purple_debug_error("gnutls/x509",
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
662 "GnuTLS error %d while checking certificate issuer match.",
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
663 ret);
19212
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
664 } else {
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
665 gchar *crt_id, *issuer_id, *crt_issuer_id;
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
666 crt_id = purple_certificate_get_unique_id(crt);
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
667 issuer_id = purple_certificate_get_unique_id(issuer);
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
668 crt_issuer_id =
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
669 purple_certificate_get_issuer_unique_id(crt);
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
670 purple_debug_info("gnutls/x509",
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
671 "Certificate for %s claims to be "
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
672 "issued by %s, but the certificate "
20284
f0a44de156fc applied changes from 54b7bcca130674c9f93777772bdf3d08237a7951
Richard Laager <rlaager@wiktel.com>
parents: 20283
diff changeset
673 "for %s does not match.\n",
20285
3b459f294dc1 applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@wiktel.com>
parents: 20284
diff changeset
674 crt_id ? crt_id : "(null)",
3b459f294dc1 applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@wiktel.com>
parents: 20284
diff changeset
675 crt_issuer_id ? crt_issuer_id : "(null)",
3b459f294dc1 applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@wiktel.com>
parents: 20284
diff changeset
676 issuer_id ? issuer_id : "(null)");
19212
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
677 g_free(crt_id);
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
678 g_free(issuer_id);
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
679 g_free(crt_issuer_id);
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
680 }
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
681
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
682 /* The issuer is not correct, or there were errors */
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
683 return FALSE;
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
684 }
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
685
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
686 /* Now, check the signature */
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
687 /* The second argument is a ptr to an array of "trusted" issuer certs,
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
688 but we're only using one trusted one */
19218
0e17da726a8c - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19215
diff changeset
689 ret = gnutls_x509_crt_verify(crt_dat, &issuer_dat, 1,
0e17da726a8c - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19215
diff changeset
690 /* Permit signings by X.509v1 certs
0e17da726a8c - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19215
diff changeset
691 (Verisign and possibly others have
0e17da726a8c - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19215
diff changeset
692 root certificates that predate the
0e17da726a8c - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19215
diff changeset
693 current standard) */
0e17da726a8c - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19215
diff changeset
694 GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT,
0e17da726a8c - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19215
diff changeset
695 &verify);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
696
19212
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
697 if (ret != 0) {
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
698 purple_debug_error("gnutls/x509",
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
699 "Attempted certificate verification caused a GnuTLS error code %d. I will just say the signature is bad, but you should look into this.\n", ret);
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
700 return FALSE;
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
701 }
19212
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
702
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
703 if (verify & GNUTLS_CERT_INVALID) {
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
704 /* Signature didn't check out, but at least
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
705 there were no errors*/
19212
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
706 gchar *crt_id = purple_certificate_get_unique_id(crt);
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
707 gchar *issuer_id = purple_certificate_get_issuer_unique_id(crt);
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
708 purple_debug_info("gnutls/x509",
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
709 "Bad signature for %s on %s\n",
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
710 issuer_id, crt_id);
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
711 g_free(crt_id);
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
712 g_free(issuer_id);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
713
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
714 return FALSE;
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
715 } /* if (ret, etc.) */
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
716
19212
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
717 /* If we got here, the signature is good */
2c7c934bfb4e - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19079
diff changeset
718 return TRUE;
18191
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
719 }
a4336814bfd4 - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18189
diff changeset
720
18935
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
721 static GByteArray *
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
722 x509_sha1sum(PurpleCertificate *crt)
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
723 {
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
724 size_t hashlen = 20; /* SHA1 hashes are 20 bytes */
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
725 size_t tmpsz = hashlen; /* Throw-away variable for GnuTLS to stomp on*/
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
726 gnutls_x509_crt crt_dat;
18935
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
727 GByteArray *hash; /**< Final hash container */
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
728 guchar hashbuf[hashlen]; /**< Temporary buffer to contain hash */
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
729
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
730 g_return_val_if_fail(crt, NULL);
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
731
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
732 crt_dat = X509_GET_GNUTLS_DATA(crt);
18935
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
733
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
734 /* Extract the fingerprint */
19492
447470c8111a - More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19491
diff changeset
735 g_return_val_if_fail(
447470c8111a - More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19491
diff changeset
736 0 == gnutls_x509_crt_get_fingerprint(crt_dat, GNUTLS_MAC_SHA,
447470c8111a - More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19491
diff changeset
737 hashbuf, &tmpsz),
447470c8111a - More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19491
diff changeset
738 NULL);
18935
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
739
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
740 /* This shouldn't happen */
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
741 g_return_val_if_fail(tmpsz == hashlen, NULL);
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
742
18935
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
743 /* Okay, now create and fill hash array */
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
744 hash = g_byte_array_new();
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
745 g_byte_array_append(hash, hashbuf, hashlen);
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
746
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
747 return hash;
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
748 }
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
749
18963
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
750 static gchar *
19079
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
751 x509_cert_dn (PurpleCertificate *crt)
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
752 {
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
753 gnutls_x509_crt cert_dat;
19079
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
754 gchar *dn = NULL;
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
755 size_t dn_size;
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
756
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
757 g_return_val_if_fail(crt, NULL);
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
758 g_return_val_if_fail(crt->scheme == &x509_gnutls, NULL);
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
759
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
760 cert_dat = X509_GET_GNUTLS_DATA(crt);
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
761
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
762 /* Figure out the length of the Distinguished Name */
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
763 /* Claim that the buffer is size 0 so GnuTLS just tells us how much
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
764 space it needs */
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
765 dn_size = 0;
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
766 gnutls_x509_crt_get_dn(cert_dat, dn, &dn_size);
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
767
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
768 /* Now allocate and get the Distinguished Name */
20283
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
769 /* Old versions of GnuTLS have an off-by-one error in reporting
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
770 the size of the needed buffer in some functions, so allocate
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
771 an extra byte */
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
772 dn = g_new0(gchar, ++dn_size);
19493
e147c3a821dd - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19492
diff changeset
773 if (0 != gnutls_x509_crt_get_dn(cert_dat, dn, &dn_size)) {
e147c3a821dd - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19492
diff changeset
774 purple_debug_error("gnutls/x509",
e147c3a821dd - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19492
diff changeset
775 "Failed to get Distinguished Name\n");
e147c3a821dd - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19492
diff changeset
776 g_free(dn);
e147c3a821dd - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19492
diff changeset
777 return NULL;
e147c3a821dd - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19492
diff changeset
778 }
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
779
19079
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
780 return dn;
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
781 }
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
782
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
783 static gchar *
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
784 x509_issuer_dn (PurpleCertificate *crt)
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
785 {
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
786 gnutls_x509_crt cert_dat;
19079
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
787 gchar *dn = NULL;
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
788 size_t dn_size;
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
789
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
790 g_return_val_if_fail(crt, NULL);
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
791 g_return_val_if_fail(crt->scheme == &x509_gnutls, NULL);
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
792
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
793 cert_dat = X509_GET_GNUTLS_DATA(crt);
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
794
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
795 /* Figure out the length of the Distinguished Name */
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
796 /* Claim that the buffer is size 0 so GnuTLS just tells us how much
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
797 space it needs */
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
798 dn_size = 0;
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
799 gnutls_x509_crt_get_issuer_dn(cert_dat, dn, &dn_size);
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
800
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
801 /* Now allocate and get the Distinguished Name */
20283
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
802 /* Old versions of GnuTLS have an off-by-one error in reporting
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
803 the size of the needed buffer in some functions, so allocate
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
804 an extra byte */
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
805 dn = g_new0(gchar, ++dn_size);
19494
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
806 if (0 != gnutls_x509_crt_get_issuer_dn(cert_dat, dn, &dn_size)) {
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
807 purple_debug_error("gnutls/x509",
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
808 "Failed to get issuer's Distinguished "
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
809 "Name\n");
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
810 g_free(dn);
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
811 return NULL;
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
812 }
19550
0a6ed4e36ca8 Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <mark@kingant.net>
parents: 19549
diff changeset
813
19079
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
814 return dn;
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
815 }
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
816
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
817 static gchar *
18963
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
818 x509_common_name (PurpleCertificate *crt)
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
819 {
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
820 gnutls_x509_crt cert_dat;
18963
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
821 gchar *cn = NULL;
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
822 size_t cn_size;
19494
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
823 int ret;
18963
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
824
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
825 g_return_val_if_fail(crt, NULL);
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
826 g_return_val_if_fail(crt->scheme == &x509_gnutls, NULL);
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
827
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
828 cert_dat = X509_GET_GNUTLS_DATA(crt);
18963
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
829
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
830 /* Figure out the length of the Common Name */
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
831 /* Claim that the buffer is size 0 so GnuTLS just tells us how much
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
832 space it needs */
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
833 cn_size = 0;
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
834 gnutls_x509_crt_get_dn_by_oid(cert_dat,
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
835 GNUTLS_OID_X520_COMMON_NAME,
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
836 0, /* First CN found, please */
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
837 0, /* Not in raw mode */
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
838 cn, &cn_size);
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
839
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
840 /* Now allocate and get the Common Name */
20283
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
841 /* Old versions of GnuTLS have an off-by-one error in reporting
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
842 the size of the needed buffer in some functions, so allocate
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
843 an extra byte */
5edb55b70108 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@wiktel.com>
parents: 20282
diff changeset
844 cn = g_new0(gchar, ++cn_size);
19494
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
845 ret = gnutls_x509_crt_get_dn_by_oid(cert_dat,
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
846 GNUTLS_OID_X520_COMMON_NAME,
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
847 0, /* First CN found, please */
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
848 0, /* Not in raw mode */
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
849 cn, &cn_size);
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
850 if (ret != 0) {
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
851 purple_debug_error("gnutls/x509",
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
852 "Failed to get Common Name\n");
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
853 g_free(cn);
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
854 return NULL;
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
855 }
280c6ec32ca6 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19493
diff changeset
856
18963
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
857 return cn;
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
858 }
146907cd3b07 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18961
diff changeset
859
19008
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
860 static gboolean
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
861 x509_check_name (PurpleCertificate *crt, const gchar *name)
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
862 {
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
863 gnutls_x509_crt crt_dat;
19008
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
864
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
865 g_return_val_if_fail(crt, FALSE);
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
866 g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE);
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
867 g_return_val_if_fail(name, FALSE);
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
868
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
869 crt_dat = X509_GET_GNUTLS_DATA(crt);
19008
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
870
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
871 if (gnutls_x509_crt_check_hostname(crt_dat, name)) {
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
872 return TRUE;
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
873 } else {
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
874 return FALSE;
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
875 }
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
876 }
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
877
19067
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
878 static gboolean
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
879 x509_times (PurpleCertificate *crt, time_t *activation, time_t *expiration)
19013
5157ebe90b93 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19008
diff changeset
880 {
20282
62b83cebbb59 applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@wiktel.com>
parents: 20255
diff changeset
881 gnutls_x509_crt crt_dat;
19067
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
882 /* GnuTLS time functions return this on error */
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
883 const time_t errval = (time_t) (-1);
20332
3a9709bfde65 applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20285
diff changeset
884 gboolean success = TRUE;
19067
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
885
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
886 g_return_val_if_fail(crt, FALSE);
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
887 g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE);
19013
5157ebe90b93 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19008
diff changeset
888
19017
e6558bae2bc6 - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19013
diff changeset
889 crt_dat = X509_GET_GNUTLS_DATA(crt);
19013
5157ebe90b93 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19008
diff changeset
890
19067
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
891 if (activation) {
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
892 *activation = gnutls_x509_crt_get_activation_time(crt_dat);
20332
3a9709bfde65 applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20285
diff changeset
893 if (*activation == errval)
3a9709bfde65 applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20285
diff changeset
894 success = FALSE;
19067
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
895 }
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
896 if (expiration) {
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
897 *expiration = gnutls_x509_crt_get_expiration_time(crt_dat);
20332
3a9709bfde65 applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20285
diff changeset
898 if (*expiration == errval)
3a9709bfde65 applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20285
diff changeset
899 success = FALSE;
19067
6c0aad79c4c5 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19021
diff changeset
900 }
19013
5157ebe90b93 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19008
diff changeset
901
20332
3a9709bfde65 applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20285
diff changeset
902 return success;
19013
5157ebe90b93 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19008
diff changeset
903 }
5157ebe90b93 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19008
diff changeset
904
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
905 /* X.509 certificate operations provided by this plugin */
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
906 static PurpleCertificateScheme x509_gnutls = {
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
907 "x509", /* Scheme name */
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
908 N_("X.509 Certificates"), /* User-visible scheme name */
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
909 x509_import_from_file, /* Certificate import function */
18977
31bdbb82de7e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18963
diff changeset
910 x509_export_certificate, /* Certificate export function */
19019
e179e7e6ded7 - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19018
diff changeset
911 x509_copy_certificate, /* Copy */
18934
04be1b885ef3 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18930
diff changeset
912 x509_destroy_certificate, /* Destroy cert */
19076
daa68185a018 - Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19067
diff changeset
913 x509_certificate_signed_by, /* Signature checker */
18935
cb9d2b9ad6bc - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18934
diff changeset
914 x509_sha1sum, /* SHA1 fingerprint */
19079
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
915 x509_cert_dn, /* Unique ID */
05ae340c42cc - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19076
diff changeset
916 x509_issuer_dn, /* Issuer Unique ID */
19006
dc60287ce426 - Add get_activation_time and get_expiration_time to CertificateScheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19004
diff changeset
917 x509_common_name, /* Subject name */
19008
7fd9bd55f8d0 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
918 x509_check_name, /* Check subject name */
19649
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19552
diff changeset
919 x509_times, /* Activation/Expiration time */
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19552
diff changeset
920
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19552
diff changeset
921 NULL,
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19552
diff changeset
922 NULL,
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19552
diff changeset
923 NULL,
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19552
diff changeset
924 NULL
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19552
diff changeset
925
18189
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
926 };
030a2209ae96 - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18188
diff changeset
927
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
928 static PurpleSslOps ssl_ops =
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 ssl_gnutls_init,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931 ssl_gnutls_uninit,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 ssl_gnutls_connect,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933 ssl_gnutls_close,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
934 ssl_gnutls_read,
16665
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
935 ssl_gnutls_write,
18187
33690062e8b3 - Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18186
diff changeset
936 ssl_gnutls_get_peer_certificates,
16665
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
937
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
938 /* padding */
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
939 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
940 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
941 NULL
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944 static gboolean
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
945 plugin_load(PurplePlugin *plugin)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
947 if(!purple_ssl_get_ops()) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
948 purple_ssl_set_ops(&ssl_ops);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951 /* 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
952 ssl_gnutls_init_gnutls();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953
19215
ab91044a914e - Move ssl-gnutls x509 registration until after GnuTLS itself is inited
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19212
diff changeset
954 /* Register that we're providing an X.509 CertScheme */
ab91044a914e - Move ssl-gnutls x509 registration until after GnuTLS itself is inited
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19212
diff changeset
955 purple_certificate_register_scheme( &x509_gnutls );
ab91044a914e - Move ssl-gnutls x509 registration until after GnuTLS itself is inited
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19212
diff changeset
956
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 static gboolean
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
961 plugin_unload(PurplePlugin *plugin)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
962 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
963 if(purple_ssl_get_ops() == &ssl_ops) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
964 purple_ssl_set_ops(NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965 }
18927
9abc911c65aa - GnuTLS plugin registers an x509 certscheme now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18191
diff changeset
966
9abc911c65aa - GnuTLS plugin registers an x509 certscheme now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18191
diff changeset
967 purple_certificate_unregister_scheme( &x509_gnutls );
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
972 static PurplePluginInfo info =
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
974 PURPLE_PLUGIN_MAGIC,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
975 PURPLE_MAJOR_VERSION,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
976 PURPLE_MINOR_VERSION,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
977 PURPLE_PLUGIN_STANDARD, /**< type */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 NULL, /**< ui_requirement */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
979 PURPLE_PLUGIN_FLAG_INVISIBLE, /**< flags */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980 NULL, /**< dependencies */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
981 PURPLE_PRIORITY_DEFAULT, /**< priority */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 SSL_GNUTLS_PLUGIN_ID, /**< id */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 N_("GNUTLS"), /**< name */
21030
3cc856ca2338 Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents: 20332
diff changeset
985 DISPLAY_VERSION, /**< version */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 /** summary */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 N_("Provides SSL support through GNUTLS."),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988 /** description */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 N_("Provides SSL support through GNUTLS."),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 "Christian Hammond <chipx86@gnupdate.org>",
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
991 PURPLE_WEBSITE, /**< homepage */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 plugin_load, /**< load */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 plugin_unload, /**< unload */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 NULL, /**< destroy */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 NULL, /**< ui_info */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 NULL, /**< extra_info */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 NULL, /**< prefs_info */
16665
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
1000 NULL, /**< actions */
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
1001
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
1002 /* padding */
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
1003 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
1004 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
1005 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15822
diff changeset
1006 NULL
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
1010 init_plugin(PurplePlugin *plugin)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15784
diff changeset
1014 PURPLE_INIT_PLUGIN(ssl_gnutls, init_plugin, info)