libpurple/plugins/ssl/ssl-gnutls.c

Sun, 01 Mar 2009 20:56:20 +0000

author
Ethan Blanton <elb@pidgin.im>
date
Sun, 01 Mar 2009 20:56:20 +0000
changeset 25643
04831cc56f5a
parent 25642
12092c956a71
child 27337
220fc9b037e5
permissions
-rw-r--r--

Use _set_default_priority on gnutls versions lacking _priority_set_direct.

Versions of gnutls prior to 2.2.0 do not have gnutls_priority_set_direct.
This fixes a compilation issue in 12092c956a719e24e522bcaf06285cb7d31080a3
on such systems. This should not represent a regression from 2.5.4 on
systems without gnutls 2.2.0 or newer.

Fixes #8526

7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file ssl-gnutls.c GNUTLS SSL plugin.
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
4 * purple
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 *
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19827
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 #include "internal.h"
7051
8ddb8f560399 [gaim-migrate @ 7614]
Christian Hammond <chipx86@chipx86.com>
parents: 7050
diff changeset
23 #include "debug.h"
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
24 #include "certificate.h"
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "plugin.h"
7051
8ddb8f560399 [gaim-migrate @ 7614]
Christian Hammond <chipx86@chipx86.com>
parents: 7050
diff changeset
26 #include "sslconn.h"
9943
b54a762f60fa [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 8749
diff changeset
27 #include "version.h"
17390
7fda160e7c5e - Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17345
diff changeset
28 #include "util.h"
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 #define SSL_GNUTLS_PLUGIN_ID "ssl-gnutls"
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 #include <gnutls/gnutls.h>
17390
7fda160e7c5e - Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17345
diff changeset
33 #include <gnutls/x509.h>
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 typedef struct
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 {
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 gnutls_session session;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
38 guint handshake_handler;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
39 } PurpleSslGnutlsData;
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
41 #define PURPLE_SSL_GNUTLS_DATA(gsc) ((PurpleSslGnutlsData *)gsc->private_data)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 static gnutls_certificate_client_credentials xcred;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44
7862
9b96706e44e7 [gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents: 7834
diff changeset
45 static void
9b96706e44e7 [gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents: 7834
diff changeset
46 ssl_gnutls_init_gnutls(void)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 {
17507
849f15622ee5 - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17442
diff changeset
48 /* Configure GnuTLS to use glib memory management */
849f15622ee5 - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17442
diff changeset
49 /* I expect that this isn't really necessary, but it may prevent
849f15622ee5 - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17442
diff changeset
50 some bugs */
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
51 /* TODO: It may be necessary to wrap this allocators for GnuTLS.
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
52 If there are strange bugs, perhaps look here (yes, I am a
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
53 hypocrite) */
17507
849f15622ee5 - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17442
diff changeset
54 gnutls_global_set_mem_functions(
23419
4e4fb7222705 I can't think of any reason we would need to use the zero versions of
Mark Doliner <markdoliner@pidgin.im>
parents: 21720
diff changeset
55 (gnutls_alloc_function) g_malloc, /* malloc */
4e4fb7222705 I can't think of any reason we would need to use the zero versions of
Mark Doliner <markdoliner@pidgin.im>
parents: 21720
diff changeset
56 (gnutls_alloc_function) g_malloc, /* secure malloc */
17507
849f15622ee5 - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17442
diff changeset
57 NULL, /* mem_is_secure */
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
58 (gnutls_realloc_function) g_realloc, /* realloc */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
59 (gnutls_free_function) g_free /* free */
17507
849f15622ee5 - GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17442
diff changeset
60 );
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
61
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 gnutls_global_init();
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 gnutls_certificate_allocate_credentials(&xcred);
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
65
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
66 /* TODO: I can likely remove this */
17430
95d550efcc3d disapproval of revision '8976f9e287fef5bd2856c34ea931afa70a997895'
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17429
diff changeset
67 gnutls_certificate_set_x509_trust_file(xcred, "ca.pem",
95d550efcc3d disapproval of revision '8976f9e287fef5bd2856c34ea931afa70a997895'
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17429
diff changeset
68 GNUTLS_X509_FMT_PEM);
7862
9b96706e44e7 [gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents: 7834
diff changeset
69 }
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70
7862
9b96706e44e7 [gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents: 7834
diff changeset
71 static gboolean
9b96706e44e7 [gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents: 7834
diff changeset
72 ssl_gnutls_init(void)
9b96706e44e7 [gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents: 7834
diff changeset
73 {
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
74 return TRUE;
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 static void
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 ssl_gnutls_uninit(void)
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 {
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 gnutls_global_deinit();
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 gnutls_certificate_free_credentials(xcred);
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
18475
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
85 static void
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
86 ssl_gnutls_verified_cb(PurpleCertificateVerificationStatus st,
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
87 gpointer userdata)
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
88 {
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
89 PurpleSslConnection *gsc = (PurpleSslConnection *) userdata;
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
90
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
91 if (st == PURPLE_CERTIFICATE_VALID) {
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
92 /* Certificate valid? Good! Do the connection! */
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
93 gsc->connect_cb(gsc->connect_cb_data, gsc, PURPLE_INPUT_READ);
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
94 } else {
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
95 /* Otherwise, signal an error */
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
96 if(gsc->error_cb != NULL)
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
97 gsc->error_cb(gsc, PURPLE_SSL_CERTIFICATE_INVALID,
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
98 gsc->connect_cb_data);
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
99 purple_ssl_close(gsc);
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
100 }
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
101 }
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
102
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
103
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
104
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
105 static void ssl_gnutls_handshake_cb(gpointer data, gint source,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
106 PurpleInputCondition cond)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
107 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
108 PurpleSslConnection *gsc = data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
109 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
110 ssize_t ret;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
111
20151
0b5ba1105191 applied changes from 5252885d793a4d288d92856d511d721bf5bb87ef
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
112 /*purple_debug_info("gnutls", "Handshaking with %s\n", gsc->host);*/
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
113 ret = gnutls_handshake(gnutls_data->session);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
114
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
115 if(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
116 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
117
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
118 purple_input_remove(gnutls_data->handshake_handler);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
119 gnutls_data->handshake_handler = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
120
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
121 if(ret != 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
122 purple_debug_error("gnutls", "Handshake failed. Error %s\n",
15846
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
123 gnutls_strerror(ret));
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
124
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
125 if(gsc->error_cb != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
126 gsc->error_cb(gsc, PURPLE_SSL_HANDSHAKE_FAILED,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
127 gsc->connect_cb_data);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
128
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
129 purple_ssl_close(gsc);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
130 } else {
18458
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
131 /* Now we are cooking with gas! */
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
132 PurpleSslOps *ops = purple_ssl_get_ops();
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
133 GList * peers = ops->get_peer_certificates(gsc);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
134
18458
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
135 PurpleCertificateScheme *x509 =
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
136 purple_certificate_find_scheme("x509");
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
137
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
138 GList * l;
19711
19b0780efe0e Fix compiler warnings about having a variable declaration after some
Mark Doliner <markdoliner@pidgin.im>
parents: 19501
diff changeset
139
19b0780efe0e Fix compiler warnings about having a variable declaration after some
Mark Doliner <markdoliner@pidgin.im>
parents: 19501
diff changeset
140 /* TODO: Remove all this debugging babble */
19b0780efe0e Fix compiler warnings about having a variable declaration after some
Mark Doliner <markdoliner@pidgin.im>
parents: 19501
diff changeset
141 purple_debug_info("gnutls", "Handshake complete\n");
19b0780efe0e Fix compiler warnings about having a variable declaration after some
Mark Doliner <markdoliner@pidgin.im>
parents: 19501
diff changeset
142
18458
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
143 for (l=peers; l; l = l->next) {
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
144 PurpleCertificate *crt = l->data;
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
145 GByteArray *z =
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
146 x509->get_fingerprint_sha1(crt);
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
147 gchar * fpr =
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
148 purple_base16_encode_chunked(z->data,
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
149 z->len);
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
150
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
151 purple_debug_info("gnutls/x509",
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
152 "Key print: %s\n",
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
153 fpr);
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
154
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
155 /* Kill the cert! */
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
156 x509->destroy_certificate(crt);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
157
18458
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
158 g_free(fpr);
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
159 g_byte_array_free(z, TRUE);
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
160 }
e2f60e9d44aa - Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18455
diff changeset
161 g_list_free(peers);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
162
17390
7fda160e7c5e - Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17345
diff changeset
163 {
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
164 const gnutls_datum *cert_list;
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
165 unsigned int cert_list_size = 0;
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
166 gnutls_session session=gnutls_data->session;
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
167 int i;
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
168
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
169 cert_list =
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
170 gnutls_certificate_get_peers(session, &cert_list_size);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
171
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
172 purple_debug_info("gnutls",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
173 "Peer provided %d certs\n",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
174 cert_list_size);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
175 for (i=0; i<cert_list_size; i++)
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
176 {
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
177 gchar fpr_bin[256];
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
178 gsize fpr_bin_sz = sizeof(fpr_bin);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
179 gchar * fpr_asc = NULL;
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
180 gchar tbuf[256];
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
181 gsize tsz=sizeof(tbuf);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
182 gchar * tasc = NULL;
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
183 gnutls_x509_crt cert;
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
184
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
185 gnutls_x509_crt_init(&cert);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
186 gnutls_x509_crt_import (cert, &cert_list[i],
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
187 GNUTLS_X509_FMT_DER);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
188
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
189 gnutls_x509_crt_get_fingerprint(cert, GNUTLS_MAC_SHA,
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
190 fpr_bin, &fpr_bin_sz);
17390
7fda160e7c5e - Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17345
diff changeset
191
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
192 fpr_asc =
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
193 purple_base16_encode_chunked((const guchar *)fpr_bin, fpr_bin_sz);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
194
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
195 purple_debug_info("gnutls",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
196 "Lvl %d SHA1 fingerprint: %s\n",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
197 i, fpr_asc);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
198
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
199 tsz=sizeof(tbuf);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
200 gnutls_x509_crt_get_serial(cert,tbuf,&tsz);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
201 tasc=purple_base16_encode_chunked((const guchar *)tbuf, tsz);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
202 purple_debug_info("gnutls",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
203 "Serial: %s\n",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
204 tasc);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
205 g_free(tasc);
17390
7fda160e7c5e - Made a big mess of stuff in the GnuTLS pluging to look at cert auth
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17345
diff changeset
206
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
207 tsz=sizeof(tbuf);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
208 gnutls_x509_crt_get_dn (cert, tbuf, &tsz);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
209 purple_debug_info("gnutls",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
210 "Cert DN: %s\n",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
211 tbuf);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
212 tsz=sizeof(tbuf);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
213 gnutls_x509_crt_get_issuer_dn (cert, tbuf, &tsz);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
214 purple_debug_info("gnutls",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
215 "Cert Issuer DN: %s\n",
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
216 tbuf);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
217
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
218 g_free(fpr_asc);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
219 fpr_asc = NULL;
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
220 gnutls_x509_crt_deinit(cert);
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
221 }
17430
95d550efcc3d disapproval of revision '8976f9e287fef5bd2856c34ea931afa70a997895'
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17429
diff changeset
222 }
18475
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
223
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
224 /* TODO: The following logic should really be in libpurple */
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
225 /* If a Verifier was given, hand control over to it */
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
226 if (gsc->verifier) {
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
227 GList *peers;
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
228 /* First, get the peer cert chain */
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
229 peers = purple_ssl_get_peer_certificates(gsc);
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
230
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
231 /* Now kick off the verification process */
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
232 purple_certificate_verify(gsc->verifier,
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
233 gsc->host,
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
234 peers,
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
235 ssl_gnutls_verified_cb,
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
236 gsc);
18656
02c822b398d2 - purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18654
diff changeset
237
02c822b398d2 - purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18654
diff changeset
238 purple_certificate_destroy_list(peers);
18475
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
239 } else {
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
240 /* Otherwise, just call the "connection complete"
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
241 callback */
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
242 gsc->connect_cb(gsc->connect_cb_data, gsc, cond);
e3893e58c4c2 - ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18458
diff changeset
243 }
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
244 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
245
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
246 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
247
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
248
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
250 ssl_gnutls_connect(PurpleSslConnection *gsc)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
252 PurpleSslGnutlsData *gnutls_data;
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 static const int cert_type_priority[2] = { GNUTLS_CRT_X509, 0 };
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
255 gnutls_data = g_new0(PurpleSslGnutlsData, 1);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 gsc->private_data = gnutls_data;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 gnutls_init(&gnutls_data->session, GNUTLS_CLIENT);
25643
04831cc56f5a Use _set_default_priority on gnutls versions lacking _priority_set_direct.
Ethan Blanton <elb@pidgin.im>
parents: 25642
diff changeset
259 #ifdef HAVE_GNUTLS_PRIORITY_FUNCS
25642
12092c956a71 patch from Martin von Gagern that uses a new gnutls option to enable better
Ka-Hing Cheung <khc@pidgin.im>
parents: 24513
diff changeset
260 if (gnutls_priority_set_direct(gnutls_data->session,
12092c956a71 patch from Martin von Gagern that uses a new gnutls option to enable better
Ka-Hing Cheung <khc@pidgin.im>
parents: 24513
diff changeset
261 "NORMAL:%SSL3_RECORD_VERSION", NULL))
12092c956a71 patch from Martin von Gagern that uses a new gnutls option to enable better
Ka-Hing Cheung <khc@pidgin.im>
parents: 24513
diff changeset
262 gnutls_priority_set_direct(gnutls_data->session, "NORMAL", NULL);
25643
04831cc56f5a Use _set_default_priority on gnutls versions lacking _priority_set_direct.
Ethan Blanton <elb@pidgin.im>
parents: 25642
diff changeset
263 #else
04831cc56f5a Use _set_default_priority on gnutls versions lacking _priority_set_direct.
Ethan Blanton <elb@pidgin.im>
parents: 25642
diff changeset
264 gnutls_set_default_priority(gnutls_data->session);
04831cc56f5a Use _set_default_priority on gnutls versions lacking _priority_set_direct.
Ethan Blanton <elb@pidgin.im>
parents: 25642
diff changeset
265 #endif
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 gnutls_certificate_type_set_priority(gnutls_data->session,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
268 cert_type_priority);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 gnutls_credentials_set(gnutls_data->session, GNUTLS_CRD_CERTIFICATE,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
271 xcred);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272
14223
c6ba4f3482de [gaim-migrate @ 16809]
Mark Doliner <markdoliner@pidgin.im>
parents: 13985
diff changeset
273 gnutls_transport_set_ptr(gnutls_data->session, GINT_TO_POINTER(gsc->fd));
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
275 gnutls_data->handshake_handler = purple_input_add(gsc->fd,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
276 PURPLE_INPUT_READ, ssl_gnutls_handshake_cb, gsc);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277
20151
0b5ba1105191 applied changes from 5252885d793a4d288d92856d511d721bf5bb87ef
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
278 purple_debug_info("gnutls", "Starting handshake with %s\n", gsc->host);
0b5ba1105191 applied changes from 5252885d793a4d288d92856d511d721bf5bb87ef
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
279
17345
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
280 /* Orborde asks: Why are we configuring a callback, then
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
281 immediately calling it?
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
282
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
283 Answer: gnutls_handshake (up in handshake_cb) needs to be called
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
284 once in order to get the ball rolling on the SSL connection.
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
285 Once it has done so, only then will the server reply, triggering
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
286 the callback.
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
287
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
288 Since the logic driving gnutls_handshake is the same with the first
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
289 and subsequent calls, we'll just fire the callback immediately to
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
290 accomplish this.
cbe9758e542e - Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 16744
diff changeset
291 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
292 ssl_gnutls_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
296 ssl_gnutls_close(PurpleSslConnection *gsc)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
298 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299
7467
a459b5408f83 [gaim-migrate @ 8080]
Nathan Walp <nwalp@pidgin.im>
parents: 7325
diff changeset
300 if(!gnutls_data)
a459b5408f83 [gaim-migrate @ 8080]
Nathan Walp <nwalp@pidgin.im>
parents: 7325
diff changeset
301 return;
a459b5408f83 [gaim-migrate @ 8080]
Nathan Walp <nwalp@pidgin.im>
parents: 7325
diff changeset
302
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
303 if(gnutls_data->handshake_handler)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
304 purple_input_remove(gnutls_data->handshake_handler);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
305
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 gnutls_bye(gnutls_data->session, GNUTLS_SHUT_RDWR);
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 gnutls_deinit(gnutls_data->session);
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 g_free(gnutls_data);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
311 gsc->private_data = NULL;
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 static size_t
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
315 ssl_gnutls_read(PurpleSslConnection *gsc, void *data, size_t len)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
317 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
318 ssize_t s;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
319
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
320 s = gnutls_record_recv(gnutls_data->session, data, len);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
322 if(s == GNUTLS_E_AGAIN || s == GNUTLS_E_INTERRUPTED) {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
323 s = -1;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
324 errno = EAGAIN;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
325 } else if(s < 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
326 purple_debug_error("gnutls", "receive failed: %s\n",
15846
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
327 gnutls_strerror(s));
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
328 s = -1;
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
329 /*
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
330 * TODO: Set errno to something more appropriate. Or even
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
331 * better: allow ssl plugins to keep track of their
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
332 * own error message, then add a new ssl_ops function
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
333 * that returns the error message.
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
334 */
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
335 errno = EIO;
7834
6a092463d774 [gaim-migrate @ 8487]
Mike Hearn <mike@theoretic.com>
parents: 7631
diff changeset
336 }
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 return s;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 static size_t
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
342 ssl_gnutls_write(PurpleSslConnection *gsc, const void *data, size_t len)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
344 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
345 ssize_t s = 0;
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
347 /* XXX: when will gnutls_data be NULL? */
7467
a459b5408f83 [gaim-migrate @ 8080]
Nathan Walp <nwalp@pidgin.im>
parents: 7325
diff changeset
348 if(gnutls_data)
a459b5408f83 [gaim-migrate @ 8080]
Nathan Walp <nwalp@pidgin.im>
parents: 7325
diff changeset
349 s = gnutls_record_send(gnutls_data->session, data, len);
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
351 if(s == GNUTLS_E_AGAIN || s == GNUTLS_E_INTERRUPTED) {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
352 s = -1;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
353 errno = EAGAIN;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
354 } else if(s < 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
355 purple_debug_error("gnutls", "send failed: %s\n",
15846
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
356 gnutls_strerror(s));
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
357 s = -1;
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
358 /*
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
359 * TODO: Set errno to something more appropriate. Or even
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
360 * better: allow ssl plugins to keep track of their
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
361 * own error message, then add a new ssl_ops function
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
362 * that returns the error message.
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
363 */
7a956b382f6c There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
364 errno = EIO;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
365 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 11513
diff changeset
366
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 return s;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369
19494
c9ee38003eb6 - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19359
diff changeset
370 /* Forward declarations are fun! */
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
371 static PurpleCertificate *
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
372 x509_import_from_datum(const gnutls_datum dt, gnutls_x509_crt_fmt mode);
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
373
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
374 static GList *
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
375 ssl_gnutls_get_peer_certificates(PurpleSslConnection * gsc)
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
376 {
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
377 PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc);
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
378
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
379 /* List of Certificate instances to return */
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
380 GList * peer_certs = NULL;
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
381
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
382 /* List of raw certificates as given by GnuTLS */
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
383 const gnutls_datum *cert_list;
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
384 unsigned int cert_list_size = 0;
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
385
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
386 unsigned int i;
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
387
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
388 /* This should never, ever happen. */
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
389 g_return_val_if_fail( gnutls_certificate_type_get (gnutls_data->session) == GNUTLS_CRT_X509, NULL);
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
390
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
391 /* Get the certificate list from GnuTLS */
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
392 /* TODO: I am _pretty sure_ this doesn't block or do other exciting things */
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
393 cert_list = gnutls_certificate_get_peers(gnutls_data->session,
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
394 &cert_list_size);
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
395
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
396 /* Convert each certificate to a Certificate and append it to the list */
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
397 for (i = 0; i < cert_list_size; i++) {
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
398 PurpleCertificate * newcrt = x509_import_from_datum(cert_list[i],
18245
2ddae03c3c9e - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17510
diff changeset
399 GNUTLS_X509_FMT_DER);
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
400 /* Append is somewhat inefficient on linked lists, but is easy
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
401 to read. If someone complains, I'll change it.
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
402 TODO: Is anyone complaining? (Maybe elb?) */
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
403 peer_certs = g_list_append(peer_certs, newcrt);
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
404 }
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
405
19494
c9ee38003eb6 - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19359
diff changeset
406 /* cert_list doesn't need free()-ing */
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
407
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
408 return peer_certs;
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
409 }
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
410
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
411 /************************************************************************/
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
412 /* X.509 functionality */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
413 /************************************************************************/
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
414 const gchar * SCHEME_NAME = "x509";
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
415
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
416 static PurpleCertificateScheme x509_gnutls;
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
417
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
418 /** Refcounted GnuTLS certificate data instance */
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
419 typedef struct {
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
420 gint refcount;
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
421 gnutls_x509_crt crt;
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
422 } x509_crtdata_t;
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
423
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
424 /** Helper functions for reference counting */
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
425 static x509_crtdata_t *
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
426 x509_crtdata_addref(x509_crtdata_t *cd)
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
427 {
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
428 (cd->refcount)++;
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
429 return cd;
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
430 }
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
431
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
432 static void
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
433 x509_crtdata_delref(x509_crtdata_t *cd)
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
434 {
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
435 (cd->refcount)--;
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
436
19714
b424012723a8 refcount of 0 is normal
Mark Doliner <markdoliner@pidgin.im>
parents: 19713
diff changeset
437 if (cd->refcount < 0)
19713
d0456ce4f4e9 Replace a call to g_assert() with a logging statement
Mark Doliner <markdoliner@pidgin.im>
parents: 19712
diff changeset
438 g_critical("Refcount of x509_crtdata_t is %d, which is less "
d0456ce4f4e9 Replace a call to g_assert() with a logging statement
Mark Doliner <markdoliner@pidgin.im>
parents: 19712
diff changeset
439 "than zero!\n", cd->refcount);
d0456ce4f4e9 Replace a call to g_assert() with a logging statement
Mark Doliner <markdoliner@pidgin.im>
parents: 19712
diff changeset
440
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
441 /* If the refcount reaches zero, kill the structure */
19713
d0456ce4f4e9 Replace a call to g_assert() with a logging statement
Mark Doliner <markdoliner@pidgin.im>
parents: 19712
diff changeset
442 if (cd->refcount <= 0) {
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
443 /* Kill the internal data */
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
444 gnutls_x509_crt_deinit( cd->crt );
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
445 /* And kill the struct */
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
446 g_free( cd );
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
447 }
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
448 }
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
449
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
450 /** Helper macro to retrieve the GnuTLS crt_t from a PurpleCertificate */
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
451 #define X509_GET_GNUTLS_DATA(pcrt) ( ((x509_crtdata_t *) (pcrt->data))->crt)
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
452
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
453 /** Transforms a gnutls_datum containing an X.509 certificate into a Certificate instance under the x509_gnutls scheme
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
454 *
18245
2ddae03c3c9e - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17510
diff changeset
455 * @param dt Datum to transform
2ddae03c3c9e - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17510
diff changeset
456 * @param mode GnuTLS certificate format specifier (GNUTLS_X509_FMT_PEM for
2ddae03c3c9e - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17510
diff changeset
457 * reading from files, and GNUTLS_X509_FMT_DER for converting
2ddae03c3c9e - Add a mode switch to allow DER or PEM imports (necessary because SSL certs
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17510
diff changeset
458 * "over the wire" certs for SSL)
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
459 *
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
460 * @return A newly allocated Certificate structure of the x509_gnutls scheme
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
461 */
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
462 static PurpleCertificate *
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
463 x509_import_from_datum(const gnutls_datum dt, gnutls_x509_crt_fmt mode)
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
464 {
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
465 /* Internal certificate data structure */
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
466 x509_crtdata_t *certdat;
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
467 /* New certificate to return */
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
468 PurpleCertificate * crt;
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
469
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
470 /* Allocate and prepare the internal certificate data */
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
471 certdat = g_new0(x509_crtdata_t, 1);
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
472 gnutls_x509_crt_init(&(certdat->crt));
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
473 certdat->refcount = 0;
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
474
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
475 /* Perform the actual certificate parse */
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
476 /* Yes, certdat->crt should be passed as-is */
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
477 gnutls_x509_crt_import(certdat->crt, &dt, mode);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
478
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
479 /* Allocate the certificate and load it with data */
18480
42936c867fee - More g_new0 instead of g_new
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18475
diff changeset
480 crt = g_new0(PurpleCertificate, 1);
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
481 crt->scheme = &x509_gnutls;
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
482 crt->data = x509_crtdata_addref(certdat);
17510
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
483
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
484 return crt;
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
485 }
b9314561d25a - Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
486
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
487 /** Imports a PEM-formatted X.509 certificate from the specified file.
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
488 * @param filename Filename to import from. Format is PEM
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
489 *
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
490 * @return A newly allocated Certificate structure of the x509_gnutls scheme
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
491 */
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
492 static PurpleCertificate *
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
493 x509_import_from_file(const gchar * filename)
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
494 {
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
495 PurpleCertificate *crt; /* Certificate being constructed */
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
496 gchar *buf; /* Used to load the raw file data */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
497 gsize buf_sz; /* Size of the above */
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
498 gnutls_datum dt; /* Struct to pass down to GnuTLS */
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
499
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
500 purple_debug_info("gnutls",
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
501 "Attempting to load X.509 certificate from %s\n",
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
502 filename);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
503
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
504 /* Next, we'll simply yank the entire contents of the file
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
505 into memory */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
506 /* TODO: Should I worry about very large files here? */
19494
c9ee38003eb6 - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19359
diff changeset
507 g_return_val_if_fail(
c9ee38003eb6 - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19359
diff changeset
508 g_file_get_contents(filename,
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
509 &buf,
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
510 &buf_sz,
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
511 NULL /* No error checking for now */
19494
c9ee38003eb6 - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19359
diff changeset
512 ),
c9ee38003eb6 - TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19359
diff changeset
513 NULL);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
514
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
515 /* Load the datum struct */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
516 dt.data = (unsigned char *) buf;
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
517 dt.size = buf_sz;
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
518
21720
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
519 /* Perform the conversion; files should be in PEM format */
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
520 crt = x509_import_from_datum(dt, GNUTLS_X509_FMT_PEM);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
521
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
522 /* Cleanup */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
523 g_free(buf);
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
524
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
525 return crt;
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
526 }
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
527
18496
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
528 /**
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
529 * Exports a PEM-formatted X.509 certificate to the specified file.
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
530 * @param filename Filename to export to. Format will be PEM
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
531 * @param crt Certificate to export
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
532 *
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
533 * @return TRUE if success, otherwise FALSE
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
534 */
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
535 static gboolean
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
536 x509_export_certificate(const gchar *filename, PurpleCertificate *crt)
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
537 {
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
538 gnutls_x509_crt crt_dat; /* GnuTLS cert struct */
18496
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
539 int ret;
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
540 gchar * out_buf; /* Data to output */
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
541 size_t out_size; /* Output size */
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
542 gboolean success = FALSE;
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
543
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
544 /* Paranoia paranoia paranoia! */
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
545 g_return_val_if_fail(filename, FALSE);
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
546 g_return_val_if_fail(crt, FALSE);
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
547 g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE);
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
548 g_return_val_if_fail(crt->data, FALSE);
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
549
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
550 crt_dat = X509_GET_GNUTLS_DATA(crt);
18496
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
551
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
552 /* Obtain the output size required */
18593
9d2bd532bf74 - Fix intermittent crash due to uninitialized variable
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18592
diff changeset
553 out_size = 0;
18496
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
554 ret = gnutls_x509_crt_export(crt_dat, GNUTLS_X509_FMT_PEM,
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
555 NULL, /* Provide no buffer yet */
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
556 &out_size /* Put size here */
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
557 );
18591
9d7c99e312b9 - Fix an incorrect assertion in GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18496
diff changeset
558 g_return_val_if_fail(ret == GNUTLS_E_SHORT_MEMORY_BUFFER, FALSE);
18496
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
559
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
560 /* Now allocate a buffer and *really* export it */
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
561 out_buf = g_new0(gchar, out_size);
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
562 ret = gnutls_x509_crt_export(crt_dat, GNUTLS_X509_FMT_PEM,
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
563 out_buf, /* Export to our new buffer */
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
564 &out_size /* Put size here */
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
565 );
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
566 if (ret != 0) {
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
567 purple_debug_error("gnutls/x509",
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
568 "Failed to export cert to buffer with code %d\n",
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
569 ret);
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
570 g_free(out_buf);
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
571 return FALSE;
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
572 }
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
573
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
574 /* Write it out to an actual file */
19501
4c14c89dcf02 - Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19497
diff changeset
575 success = purple_util_write_data_to_file_absolute(filename,
4c14c89dcf02 - Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19497
diff changeset
576 out_buf, out_size);
18496
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
577
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
578 g_free(out_buf);
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
579 g_return_val_if_fail(success, FALSE);
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
580 return success;
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
581 }
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
582
18654
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
583 static PurpleCertificate *
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
584 x509_copy_certificate(PurpleCertificate *crt)
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
585 {
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
586 x509_crtdata_t *crtdat;
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
587 PurpleCertificate *newcrt;
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
588
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
589 g_return_val_if_fail(crt, NULL);
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
590 g_return_val_if_fail(crt->scheme == &x509_gnutls, NULL);
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
591
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
592 crtdat = (x509_crtdata_t *) crt->data;
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
593
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
594 newcrt = g_new0(PurpleCertificate, 1);
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
595 newcrt->scheme = &x509_gnutls;
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
596 newcrt->data = x509_crtdata_addref(crtdat);
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
597
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
598 return newcrt;
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
599 }
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
600 /** Frees a Certificate
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
601 *
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
602 * Destroys a Certificate's internal data structures and frees the pointer
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
603 * given.
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
604 * @param crt Certificate instance to be destroyed. It WILL NOT be destroyed
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
605 * if it is not of the correct CertificateScheme. Can be NULL
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
606 *
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
607 */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
608 static void
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
609 x509_destroy_certificate(PurpleCertificate * crt)
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
610 {
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
611 if (NULL == crt) return;
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
612
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
613 /* Check that the scheme is x509_gnutls */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
614 if ( crt->scheme != &x509_gnutls ) {
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
615 purple_debug_error("gnutls",
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
616 "destroy_certificate attempted on certificate of wrong scheme (scheme was %s, expected %s)\n",
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
617 crt->scheme->name,
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
618 SCHEME_NAME);
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
619 return;
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
620 }
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
621
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
622 g_return_if_fail(crt->data != NULL);
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
623 g_return_if_fail(crt->scheme != NULL);
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
624
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
625 /* Use the reference counting system to free (or not) the
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
626 underlying data */
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
627 x509_crtdata_delref((x509_crtdata_t *)crt->data);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
628
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
629 /* Kill the structure itself */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
630 g_free(crt);
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
631 }
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17507
diff changeset
632
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
633 /** Determines whether one certificate has been issued and signed by another
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
634 *
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
635 * @param crt Certificate to check the signature of
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
636 * @param issuer Issuer's certificate
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
637 *
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
638 * @return TRUE if crt was signed and issued by issuer, otherwise FALSE
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
639 * @TODO Modify this function to return a reason for invalidity?
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
640 */
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
641 static gboolean
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
642 x509_certificate_signed_by(PurpleCertificate * crt,
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
643 PurpleCertificate * issuer)
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
644 {
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
645 gnutls_x509_crt crt_dat;
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
646 gnutls_x509_crt issuer_dat;
19353
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
647 unsigned int verify; /* used to store result from GnuTLS verifier */
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
648 int ret;
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
649
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
650 g_return_val_if_fail(crt, FALSE);
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
651 g_return_val_if_fail(issuer, FALSE);
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
652
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
653 /* Verify that both certs are the correct scheme */
18482
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
654 g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE);
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
655 g_return_val_if_fail(issuer->scheme == &x509_gnutls, FALSE);
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
656
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
657 /* TODO: check for more nullness? */
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
658
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
659 crt_dat = X509_GET_GNUTLS_DATA(crt);
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
660 issuer_dat = X509_GET_GNUTLS_DATA(issuer);
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
661
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
662 /* First, let's check that crt.issuer is actually issuer */
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
663 ret = gnutls_x509_crt_check_issuer(crt_dat, issuer_dat);
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
664 if (ret <= 0) {
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
665
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
666 if (ret < 0) {
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
667 purple_debug_error("gnutls/x509",
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
668 "GnuTLS error %d while checking certificate issuer match.",
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
669 ret);
19353
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
670 } else {
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
671 gchar *crt_id, *issuer_id, *crt_issuer_id;
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
672 crt_id = purple_certificate_get_unique_id(crt);
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
673 issuer_id = purple_certificate_get_unique_id(issuer);
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
674 crt_issuer_id =
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
675 purple_certificate_get_issuer_unique_id(crt);
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
676 purple_debug_info("gnutls/x509",
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
677 "Certificate for %s claims to be "
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
678 "issued by %s, but the certificate "
20176
5d7a12420da4 applied changes from 54b7bcca130674c9f93777772bdf3d08237a7951
Richard Laager <rlaager@pidgin.im>
parents: 20175
diff changeset
679 "for %s does not match.\n",
20177
92af9f603b75 applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@pidgin.im>
parents: 20176
diff changeset
680 crt_id ? crt_id : "(null)",
92af9f603b75 applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@pidgin.im>
parents: 20176
diff changeset
681 crt_issuer_id ? crt_issuer_id : "(null)",
92af9f603b75 applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@pidgin.im>
parents: 20176
diff changeset
682 issuer_id ? issuer_id : "(null)");
19353
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
683 g_free(crt_id);
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
684 g_free(issuer_id);
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
685 g_free(crt_issuer_id);
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
686 }
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
687
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
688 /* The issuer is not correct, or there were errors */
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
689 return FALSE;
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
690 }
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
691
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
692 /* Now, check the signature */
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
693 /* The second argument is a ptr to an array of "trusted" issuer certs,
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
694 but we're only using one trusted one */
19359
8961d49b1b87 - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19356
diff changeset
695 ret = gnutls_x509_crt_verify(crt_dat, &issuer_dat, 1,
8961d49b1b87 - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19356
diff changeset
696 /* Permit signings by X.509v1 certs
8961d49b1b87 - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19356
diff changeset
697 (Verisign and possibly others have
8961d49b1b87 - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19356
diff changeset
698 root certificates that predate the
8961d49b1b87 - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19356
diff changeset
699 current standard) */
8961d49b1b87 - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19356
diff changeset
700 GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT,
8961d49b1b87 - x509_signed_by now accepts a signature by an X.509 version 1
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19356
diff changeset
701 &verify);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
702
19353
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
703 if (ret != 0) {
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
704 purple_debug_error("gnutls/x509",
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
705 "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);
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
706 return FALSE;
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
707 }
19353
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
708
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
709 if (verify & GNUTLS_CERT_INVALID) {
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
710 /* Signature didn't check out, but at least
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
711 there were no errors*/
19353
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
712 gchar *crt_id = purple_certificate_get_unique_id(crt);
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
713 gchar *issuer_id = purple_certificate_get_issuer_unique_id(crt);
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
714 purple_debug_info("gnutls/x509",
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
715 "Bad signature for %s on %s\n",
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
716 issuer_id, crt_id);
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
717 g_free(crt_id);
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
718 g_free(issuer_id);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
719
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
720 return FALSE;
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
721 } /* if (ret, etc.) */
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
722
19353
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
723 /* If we got here, the signature is good */
bf6a0230d8e7 - Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19019
diff changeset
724 return TRUE;
18250
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
725 }
d7663374e33d - Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
726
18455
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
727 static GByteArray *
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
728 x509_sha1sum(PurpleCertificate *crt)
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
729 {
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
730 size_t hashlen = 20; /* SHA1 hashes are 20 bytes */
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
731 size_t tmpsz = hashlen; /* Throw-away variable for GnuTLS to stomp on*/
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
732 gnutls_x509_crt crt_dat;
18455
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
733 GByteArray *hash; /**< Final hash container */
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
734 guchar hashbuf[hashlen]; /**< Temporary buffer to contain hash */
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
735
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
736 g_return_val_if_fail(crt, NULL);
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
737
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
738 crt_dat = X509_GET_GNUTLS_DATA(crt);
18455
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
739
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
740 /* Extract the fingerprint */
19495
af7b321844ab - More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19494
diff changeset
741 g_return_val_if_fail(
af7b321844ab - More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19494
diff changeset
742 0 == gnutls_x509_crt_get_fingerprint(crt_dat, GNUTLS_MAC_SHA,
af7b321844ab - More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19494
diff changeset
743 hashbuf, &tmpsz),
af7b321844ab - More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19494
diff changeset
744 NULL);
18455
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
745
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
746 /* This shouldn't happen */
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
747 g_return_val_if_fail(tmpsz == hashlen, NULL);
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
748
18455
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
749 /* Okay, now create and fill hash array */
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
750 hash = g_byte_array_new();
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
751 g_byte_array_append(hash, hashbuf, hashlen);
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
752
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
753 return hash;
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
754 }
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
755
18482
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
756 static gchar *
19019
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
757 x509_cert_dn (PurpleCertificate *crt)
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
758 {
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
759 gnutls_x509_crt cert_dat;
19019
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
760 gchar *dn = NULL;
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
761 size_t dn_size;
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
762
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
763 g_return_val_if_fail(crt, NULL);
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
764 g_return_val_if_fail(crt->scheme == &x509_gnutls, NULL);
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
765
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
766 cert_dat = X509_GET_GNUTLS_DATA(crt);
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
767
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
768 /* Figure out the length of the Distinguished Name */
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
769 /* Claim that the buffer is size 0 so GnuTLS just tells us how much
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
770 space it needs */
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
771 dn_size = 0;
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
772 gnutls_x509_crt_get_dn(cert_dat, dn, &dn_size);
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
773
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
774 /* Now allocate and get the Distinguished Name */
20175
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
775 /* Old versions of GnuTLS have an off-by-one error in reporting
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
776 the size of the needed buffer in some functions, so allocate
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
777 an extra byte */
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
778 dn = g_new0(gchar, ++dn_size);
19496
648d59dc3bfa - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19495
diff changeset
779 if (0 != gnutls_x509_crt_get_dn(cert_dat, dn, &dn_size)) {
648d59dc3bfa - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19495
diff changeset
780 purple_debug_error("gnutls/x509",
648d59dc3bfa - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19495
diff changeset
781 "Failed to get Distinguished Name\n");
648d59dc3bfa - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19495
diff changeset
782 g_free(dn);
648d59dc3bfa - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19495
diff changeset
783 return NULL;
648d59dc3bfa - Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19495
diff changeset
784 }
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
785
19019
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
786 return dn;
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
787 }
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
788
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
789 static gchar *
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
790 x509_issuer_dn (PurpleCertificate *crt)
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
791 {
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
792 gnutls_x509_crt cert_dat;
19019
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
793 gchar *dn = NULL;
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
794 size_t dn_size;
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
795
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
796 g_return_val_if_fail(crt, NULL);
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
797 g_return_val_if_fail(crt->scheme == &x509_gnutls, NULL);
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
798
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
799 cert_dat = X509_GET_GNUTLS_DATA(crt);
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
800
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
801 /* Figure out the length of the Distinguished Name */
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
802 /* Claim that the buffer is size 0 so GnuTLS just tells us how much
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
803 space it needs */
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
804 dn_size = 0;
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
805 gnutls_x509_crt_get_issuer_dn(cert_dat, dn, &dn_size);
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
806
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
807 /* Now allocate and get the Distinguished Name */
20175
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
808 /* Old versions of GnuTLS have an off-by-one error in reporting
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
809 the size of the needed buffer in some functions, so allocate
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
810 an extra byte */
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
811 dn = g_new0(gchar, ++dn_size);
19497
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
812 if (0 != gnutls_x509_crt_get_issuer_dn(cert_dat, dn, &dn_size)) {
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
813 purple_debug_error("gnutls/x509",
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
814 "Failed to get issuer's Distinguished "
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
815 "Name\n");
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
816 g_free(dn);
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
817 return NULL;
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
818 }
19712
658159391efc Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents: 19711
diff changeset
819
19019
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
820 return dn;
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
821 }
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
822
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
823 static gchar *
18482
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
824 x509_common_name (PurpleCertificate *crt)
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
825 {
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
826 gnutls_x509_crt cert_dat;
18482
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
827 gchar *cn = NULL;
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
828 size_t cn_size;
19497
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
829 int ret;
18482
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
830
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
831 g_return_val_if_fail(crt, NULL);
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
832 g_return_val_if_fail(crt->scheme == &x509_gnutls, NULL);
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
833
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
834 cert_dat = X509_GET_GNUTLS_DATA(crt);
18482
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
835
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
836 /* Figure out the length of the Common Name */
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
837 /* Claim that the buffer is size 0 so GnuTLS just tells us how much
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
838 space it needs */
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
839 cn_size = 0;
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
840 gnutls_x509_crt_get_dn_by_oid(cert_dat,
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
841 GNUTLS_OID_X520_COMMON_NAME,
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
842 0, /* First CN found, please */
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
843 0, /* Not in raw mode */
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
844 cn, &cn_size);
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
845
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
846 /* Now allocate and get the Common Name */
20175
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
847 /* Old versions of GnuTLS have an off-by-one error in reporting
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
848 the size of the needed buffer in some functions, so allocate
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
849 an extra byte */
0785c8f62a58 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents: 20174
diff changeset
850 cn = g_new0(gchar, ++cn_size);
19497
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
851 ret = gnutls_x509_crt_get_dn_by_oid(cert_dat,
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
852 GNUTLS_OID_X520_COMMON_NAME,
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
853 0, /* First CN found, please */
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
854 0, /* Not in raw mode */
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
855 cn, &cn_size);
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
856 if (ret != 0) {
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
857 purple_debug_error("gnutls/x509",
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
858 "Failed to get Common Name\n");
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
859 g_free(cn);
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
860 return NULL;
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
861 }
9766bb35cc02 - Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19496
diff changeset
862
18482
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
863 return cn;
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
864 }
be73de06d821 - Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18480
diff changeset
865
18643
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
866 static gboolean
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
867 x509_check_name (PurpleCertificate *crt, const gchar *name)
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
868 {
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
869 gnutls_x509_crt crt_dat;
18643
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
870
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
871 g_return_val_if_fail(crt, FALSE);
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
872 g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE);
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
873 g_return_val_if_fail(name, FALSE);
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
874
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
875 crt_dat = X509_GET_GNUTLS_DATA(crt);
18643
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
876
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
877 if (gnutls_x509_crt_check_hostname(crt_dat, name)) {
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
878 return TRUE;
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
879 } else {
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
880 return FALSE;
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
881 }
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
882 }
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
883
19007
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
884 static gboolean
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
885 x509_times (PurpleCertificate *crt, time_t *activation, time_t *expiration)
18648
a677b7c8fd97 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18643
diff changeset
886 {
20174
dc85e2b0d3da applied changes from 8b8bc5b1ef1263e1c0f00a9ed208accff09d988e
Richard Laager <rlaager@pidgin.im>
parents: 20151
diff changeset
887 gnutls_x509_crt crt_dat;
19007
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
888 /* GnuTLS time functions return this on error */
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
889 const time_t errval = (time_t) (-1);
20224
d4b827c606db applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20177
diff changeset
890 gboolean success = TRUE;
19007
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
891
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
892 g_return_val_if_fail(crt, FALSE);
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
893 g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE);
18648
a677b7c8fd97 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18643
diff changeset
894
18652
0998769e4fea - GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18648
diff changeset
895 crt_dat = X509_GET_GNUTLS_DATA(crt);
18648
a677b7c8fd97 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18643
diff changeset
896
19007
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
897 if (activation) {
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
898 *activation = gnutls_x509_crt_get_activation_time(crt_dat);
20224
d4b827c606db applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20177
diff changeset
899 if (*activation == errval)
d4b827c606db applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20177
diff changeset
900 success = FALSE;
19007
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
901 }
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
902 if (expiration) {
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
903 *expiration = gnutls_x509_crt_get_expiration_time(crt_dat);
20224
d4b827c606db applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20177
diff changeset
904 if (*expiration == errval)
d4b827c606db applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20177
diff changeset
905 success = FALSE;
19007
f3c3ddf37812 - Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18656
diff changeset
906 }
18648
a677b7c8fd97 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18643
diff changeset
907
20224
d4b827c606db applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents: 20177
diff changeset
908 return success;
18648
a677b7c8fd97 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18643
diff changeset
909 }
a677b7c8fd97 - Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18643
diff changeset
910
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
911 /* X.509 certificate operations provided by this plugin */
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
912 static PurpleCertificateScheme x509_gnutls = {
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
913 "x509", /* Scheme name */
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
914 N_("X.509 Certificates"), /* User-visible scheme name */
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
915 x509_import_from_file, /* Certificate import function */
18496
3bb8e716482e - Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18482
diff changeset
916 x509_export_certificate, /* Certificate export function */
18654
45790c3e780d - Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18653
diff changeset
917 x509_copy_certificate, /* Copy */
18454
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18450
diff changeset
918 x509_destroy_certificate, /* Destroy cert */
19016
3cf632c31eb3 - Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19007
diff changeset
919 x509_certificate_signed_by, /* Signature checker */
18455
4fe7da78f38d - Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
920 x509_sha1sum, /* SHA1 fingerprint */
19019
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
921 x509_cert_dn, /* Unique ID */
d2415aad4cfb - Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19016
diff changeset
922 x509_issuer_dn, /* Issuer Unique ID */
18641
4b3c12392054 - Add get_activation_time and get_expiration_time to CertificateScheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18593
diff changeset
923 x509_common_name, /* Subject name */
18643
a6a86ac3c219 - Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18642
diff changeset
924 x509_check_name, /* Check subject name */
19827
62c3805f723e - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19714
diff changeset
925 x509_times, /* Activation/Expiration time */
62c3805f723e - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19714
diff changeset
926
62c3805f723e - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19714
diff changeset
927 NULL,
62c3805f723e - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19714
diff changeset
928 NULL,
62c3805f723e - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19714
diff changeset
929 NULL,
62c3805f723e - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19714
diff changeset
930 NULL
62c3805f723e - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19714
diff changeset
931
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
932 };
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
933
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
934 static PurpleSslOps ssl_ops =
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
935 {
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
936 ssl_gnutls_init,
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
937 ssl_gnutls_uninit,
14223
c6ba4f3482de [gaim-migrate @ 16809]
Mark Doliner <markdoliner@pidgin.im>
parents: 13985
diff changeset
938 ssl_gnutls_connect,
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
939 ssl_gnutls_close,
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
940 ssl_gnutls_read,
16744
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
941 ssl_gnutls_write,
18246
212bfb9c9cc7 - Expose get_peer_certificates in the SslOps struct, and modify gnutls
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18245
diff changeset
942 ssl_gnutls_get_peer_certificates,
16744
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
943
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
944 /* padding */
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
945 NULL,
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
946 NULL,
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
947 NULL
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
948 };
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
949
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
950 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
951 plugin_load(PurplePlugin *plugin)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
952 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
953 if(!purple_ssl_get_ops()) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
954 purple_ssl_set_ops(&ssl_ops);
7862
9b96706e44e7 [gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents: 7834
diff changeset
955 }
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
956
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 9943
diff changeset
957 /* Init GNUTLS now so others can use it even if sslconn never does */
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 9943
diff changeset
958 ssl_gnutls_init_gnutls();
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 9943
diff changeset
959
19356
65dacaaad968 - Move ssl-gnutls x509 registration until after GnuTLS itself is inited
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19353
diff changeset
960 /* Register that we're providing an X.509 CertScheme */
65dacaaad968 - Move ssl-gnutls x509 registration until after GnuTLS itself is inited
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19353
diff changeset
961 purple_certificate_register_scheme( &x509_gnutls );
65dacaaad968 - Move ssl-gnutls x509 registration until after GnuTLS itself is inited
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19353
diff changeset
962
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
963 return TRUE;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
964 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
965
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
966 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
967 plugin_unload(PurplePlugin *plugin)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
968 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
969 if(purple_ssl_get_ops() == &ssl_ops) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
970 purple_ssl_set_ops(NULL);
7862
9b96706e44e7 [gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents: 7834
diff changeset
971 }
18447
27554a183269 - GnuTLS plugin registers an x509 certscheme now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18250
diff changeset
972
27554a183269 - GnuTLS plugin registers an x509 certscheme now
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18250
diff changeset
973 purple_certificate_unregister_scheme( &x509_gnutls );
7050
12730863b0f9 [gaim-migrate @ 7613]
Christian Hammond <chipx86@chipx86.com>
parents: 7016
diff changeset
974
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
975 return TRUE;
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
976 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
977
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
978 static PurplePluginInfo info =
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
979 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
980 PURPLE_PLUGIN_MAGIC,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
981 PURPLE_MAJOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
982 PURPLE_MINOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
983 PURPLE_PLUGIN_STANDARD, /**< type */
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
984 NULL, /**< ui_requirement */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
985 PURPLE_PLUGIN_FLAG_INVISIBLE, /**< flags */
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
986 NULL, /**< dependencies */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
987 PURPLE_PRIORITY_DEFAULT, /**< priority */
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
988
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
989 SSL_GNUTLS_PLUGIN_ID, /**< id */
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
990 N_("GNUTLS"), /**< name */
20288
5ca925a094e2 applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 20224
diff changeset
991 DISPLAY_VERSION, /**< version */
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
992 /** summary */
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
993 N_("Provides SSL support through GNUTLS."),
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
994 /** description */
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
995 N_("Provides SSL support through GNUTLS."),
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
996 "Christian Hammond <chipx86@gnupdate.org>",
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
997 PURPLE_WEBSITE, /**< homepage */
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
998
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
999 plugin_load, /**< load */
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1000 plugin_unload, /**< unload */
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1001 NULL, /**< destroy */
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1002
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1003 NULL, /**< ui_info */
11513
89bf8d856291 [gaim-migrate @ 13758]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11256
diff changeset
1004 NULL, /**< extra_info */
89bf8d856291 [gaim-migrate @ 13758]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11256
diff changeset
1005 NULL, /**< prefs_info */
16744
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
1006 NULL, /**< actions */
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
1007
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
1008 /* padding */
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
1009 NULL,
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
1010 NULL,
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
1011 NULL,
fcdab37ba1c2 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 15884
diff changeset
1012 NULL
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1013 };
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1014
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1015 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
1016 init_plugin(PurplePlugin *plugin)
7016
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1017 {
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1018 }
895a5ff9ebd4 [gaim-migrate @ 7579]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1019
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15846
diff changeset
1020 PURPLE_INIT_PLUGIN(ssl_gnutls, init_plugin, info)

mercurial