Wed, 26 Nov 2014 16:01:25 +0530
Merged default branch
| 7016 | 1 | /** |
| 2 | * @file ssl-gnutls.c GNUTLS SSL plugin. | |
| 3 | * | |
| 15884 | 4 | * purple |
| 7016 | 5 | * |
| 6 | * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 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 | 21 | */ |
| 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" |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
34246
diff
changeset
|
25 | #include "plugins.h" |
|
7051
8ddb8f560399
[gaim-migrate @ 7614]
Christian Hammond <chipx86@chipx86.com>
parents:
7050
diff
changeset
|
26 | #include "sslconn.h" |
| 9943 | 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 | 29 | |
| 30 | #define SSL_GNUTLS_PLUGIN_ID "ssl-gnutls" | |
| 31 | ||
| 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 | 34 | |
| 35 | typedef struct | |
| 36 | { | |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
37 | gnutls_session_t session; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
38 | guint handshake_handler; |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
39 | guint handshake_timer; |
| 15884 | 40 | } PurpleSslGnutlsData; |
| 7016 | 41 | |
| 15884 | 42 | #define PURPLE_SSL_GNUTLS_DATA(gsc) ((PurpleSslGnutlsData *)gsc->private_data) |
| 7016 | 43 | |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
44 | static gnutls_certificate_client_credentials xcred = NULL; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
45 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
46 | #ifdef HAVE_GNUTLS_PRIORITY_FUNCS |
|
36155
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
47 | |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
48 | /** |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
49 | * This string tells GnuTLS the list of ciphers we're ok with using. The goal |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
50 | * is to disable weaker ciphers while remaining compatible with almost all |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
51 | * servers. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
52 | * |
|
36156
2fe784e7e985
Add note that it would be better if we didn't specify the ciphers ourselves.
Mark Doliner <mark@kingant.net>
parents:
36155
diff
changeset
|
53 | * Ideally this is something we wouldn't do. Ideally the system-wide GnuTLS |
|
2fe784e7e985
Add note that it would be better if we didn't specify the ciphers ourselves.
Mark Doliner <mark@kingant.net>
parents:
36155
diff
changeset
|
54 | * library would use good defaults. But for now I think we can safely be more |
|
2fe784e7e985
Add note that it would be better if we didn't specify the ciphers ourselves.
Mark Doliner <mark@kingant.net>
parents:
36155
diff
changeset
|
55 | * restrictive than the GnuTLS defaults. --Mark Doliner |
|
2fe784e7e985
Add note that it would be better if we didn't specify the ciphers ourselves.
Mark Doliner <mark@kingant.net>
parents:
36155
diff
changeset
|
56 | * |
|
36155
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
57 | * You can test the priority string using this command: |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
58 | * > gnutls-cli --priority "<SIGNATURE STRING>" <HOSTNAME> |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
59 | * Note that on Ubuntu 14.04 gnutls-cli is linked against the older GnuTLS |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
60 | * 2.12.23, which might be different than what Pidgin is linked against. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
61 | * |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
62 | * Rationale for this string: |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
63 | * - Start with the SECURE192 keyword and add the SECURE128 keyword. This |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
64 | * includes both 128 and 192 bit ciphers, giving priority to the 192 bit |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
65 | * ciphers. We're not too picky about the order... people generally think |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
66 | * 128 bit ciphers are sufficient for now and 192 bit ciphers are overkill |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
67 | * (and slower), but the speed impact shouldn't matter much for us and we |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
68 | * prefer to be resilient into the distant future. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
69 | * |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
70 | * - Remove and re-add RSA ciphers. This gives them a lower priority. We do |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
71 | * this because they don't support perfect forward secrecy (PFS) and we want |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
72 | * ciphers that DO support PFS to have a higher priority. An alternate way |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
73 | * to do this is to add +PFS to the front of the string, but the PFS keyword |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
74 | * was only added in 3.2.4 and attempting to use it with older GnuTLS causes |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
75 | * the entire priority string to be discarded. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
76 | * |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
77 | * - Add SIGN-RSA-SHA1. SHA-1 is a weaker hashing algorithm that's not |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
78 | * included in SECURE128. We'd prefer not to include it, but unfortunately |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
79 | * as of 2014-09-10 it is required by login.live.com (used by the MSN PRPL). |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
80 | * |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
81 | * - Remove DHE-DSS ciphers. This is kind of arbitrary. We think maybe nobody |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
82 | * uses these and all things being equal a shorter cipher list is preferred. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
83 | * |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
84 | * - Disable SSL 3.0. Everyone should be using at least TLS 1.0 by now. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
85 | * |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
86 | * We only use this string for GnuTLS 3.2.2 and newer. For older versions we |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
87 | * use NORMAL. Over time the GnuTLS library has changed how it parses priority |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
88 | * strings and there are some unfortunate quirks: |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
89 | * - 128 bit ciphers stopped being included in the SECURE256 keyword in 3.0.9. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
90 | * - 256 bit ciphers started being included in the SECURE128 keyword in 3.0.12. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
91 | * - Support for combining priority string keywords wasn't added until 3.1.0. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
92 | * - Adding/removing items from the priority string using plus and minus is |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
93 | * buggy in GnuTLS 3.2.2 and older. See this commit for details: |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
94 | * https://gitorious.org/gnutls/gnutls/commit/913f03ccfafc37277f0a88287d02cdbb9bbfb652 |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
95 | * |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
96 | * These quirks make it difficult to find a single priority string that works |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
97 | * well for all versions of GnuTLS that enables 128 and 256 bit ciphers while |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
98 | * disabling less secure ciphers. In fact it's difficult to come up with ANY |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
99 | * string that accomplishes this for 3.0.9, 3.0.10, and 3.0.11. And the bug |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
100 | * with adding/removing items from the priority string means we might get |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
101 | * unexpected results when using a complicated string, and so we're better off |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
102 | * just sticking with the default. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
103 | * |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
104 | * For more discussion about this change see bug #8061. |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
105 | */ |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
106 | #define GNUTLS_DEFAULT_PRIORITY "SECURE192:+SECURE128:-RSA:+RSA:+SIGN-RSA-SHA1:-DHE-DSS:-VERS-SSL3.0" |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
107 | |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
108 | /* |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
109 | * Priority strings. The default one is, well, the default (and is always |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
110 | * set). The hash table is of the form hostname => priority (both |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
111 | * char *). |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
112 | * |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
113 | * We only use a gnutls_priority_t for the default on the assumption that |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
114 | * that's the more common case. Improvement patches (like matching on |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
115 | * subdomains) welcome. |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
116 | */ |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
117 | static gnutls_priority_t default_priority = NULL; |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
118 | static GHashTable *host_priorities = NULL; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
119 | #endif |
| 7016 | 120 | |
|
36213
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
121 | static gchar *x509_cert_dn(PurpleCertificate *crt); |
|
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
122 | static gchar *x509_issuer_dn(PurpleCertificate *crt); |
|
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
123 | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
124 | static void |
|
27407
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
125 | ssl_gnutls_log(int level, const char *str) |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
126 | { |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
127 | /* GnuTLS log messages include the '\n' */ |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
128 | purple_debug_misc("gnutls", "lvl %d: %s", level, str); |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
129 | } |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
130 | |
|
36154
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
131 | /** |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
132 | * set_cipher_priorities: |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
133 | * @priority_cache: A pointer to a gnutls_priority_t. This will be initialized |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
134 | * using the given priorities. |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
135 | * @priorities: A GnuTLS priority string. |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
136 | * |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
137 | * A simple convenience wrapper around gnutls_priority_init(). The wrapper |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
138 | * does a few things: |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
139 | * - Logs a helpful message if initialization fails. |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
140 | * - Frees priority_cache if needed if initialization fails. |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
141 | * - Set priority_cache to NULL if needed if initialization fails. |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
142 | */ |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
143 | static void |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
144 | set_cipher_priorities(gnutls_priority_t *priority_cache, const char *priorities) |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
145 | { |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
146 | int ret; |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
147 | |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
148 | ret = gnutls_priority_init(priority_cache, priorities, NULL); |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
149 | if (ret != GNUTLS_E_SUCCESS) { |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
150 | purple_debug_warning("gnutls", "Unable to set cipher priorities to %s. " |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
151 | "Error code %d: %s\n", priorities, ret, gnutls_strerror(ret)); |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
152 | |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
153 | /* Versions of GnuTLS before 2.9.10 allocate but don't free priority_cache |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
154 | if there's an error. We free it here to avoid a mem leak. */ |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
155 | if (!gnutls_check_version("2.9.10")) { |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
156 | gnutls_free(*priority_cache); |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
157 | } |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
158 | |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
159 | /* Versions of GnuTLS before 3.2.9 leave priority_cache pointing to |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
160 | freed memory if there's an error. We want our callers to be able to |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
161 | depend on this being NULL, so set it to NULL ourselves. */ |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
162 | if (!gnutls_check_version("3.2.9")) { |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
163 | *priority_cache = NULL; |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
164 | } |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
165 | } |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
166 | } |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
167 | |
|
27407
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
168 | static void |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
169 | ssl_gnutls_init_gnutls(void) |
| 7016 | 170 | { |
|
27407
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
171 | const char *debug_level; |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
172 | const char *host_priorities_str; |
|
27407
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
173 | |
|
17507
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
174 | /* Configure GnuTLS to use glib memory management */ |
|
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
175 | /* 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
|
176 | some bugs */ |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
177 | /* 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
|
178 | 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
|
179 | hypocrite) */ |
|
17507
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
180 | 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
|
181 | (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
|
182 | (gnutls_alloc_function) g_malloc, /* secure malloc */ |
|
17507
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
183 | NULL, /* mem_is_secure */ |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
184 | (gnutls_realloc_function) g_realloc, /* realloc */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
185 | (gnutls_free_function) g_free /* free */ |
|
17507
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
186 | ); |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
187 | |
|
27407
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
188 | debug_level = g_getenv("PURPLE_GNUTLS_DEBUG"); |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
189 | if (debug_level) { |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
190 | int level = atoi(debug_level); |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
191 | if (level < 0) { |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
192 | purple_debug_warning("gnutls", "Assuming log level 0 instead of %d\n", |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
193 | level); |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
194 | level = 0; |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
195 | } |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
196 | |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
197 | /* "The level is an integer between 0 and 9. Higher values mean more verbosity." */ |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
198 | gnutls_global_set_log_level(level); |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
199 | gnutls_global_set_log_function(ssl_gnutls_log); |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
200 | } |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
201 | |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
202 | /* Expected format: host=priority;host2=priority;*=priority |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
203 | * where "*" is used to override the default priority string for |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
204 | * libpurple. |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
205 | */ |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
206 | host_priorities_str = g_getenv("PURPLE_GNUTLS_PRIORITIES"); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
207 | if (host_priorities_str) { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
208 | #ifndef HAVE_GNUTLS_PRIORITY_FUNCS |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
209 | purple_debug_warning("gnutls", "Warning, PURPLE_GNUTLS_PRIORITIES " |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
210 | "environment variable set, but we were built " |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
211 | "against an older GnuTLS that doesn't support " |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
212 | "this. :-("); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
213 | #else /* HAVE_GNUTLS_PRIORITY_FUNCS */ |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
214 | char **entries = g_strsplit(host_priorities_str, ";", -1); |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
215 | char *default_priority_str = NULL; |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
216 | guint i; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
217 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
218 | host_priorities = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
219 | g_free, g_free); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
220 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
221 | for (i = 0; entries[i]; ++i) { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
222 | char *host = entries[i]; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
223 | char *equals = strchr(host, '='); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
224 | char *prio_str; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
225 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
226 | if (equals) { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
227 | *equals = '\0'; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
228 | prio_str = equals + 1; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
229 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
230 | /* Empty? */ |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
231 | if (*prio_str == '\0') { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
232 | purple_debug_warning("gnutls", "Ignoring empty priority " |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
233 | "string for %s\n", host); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
234 | } else { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
235 | /* TODO: Validate each of these and complain */ |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
236 | if (g_str_equal(host, "*")) { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
237 | /* Override the default priority */ |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
238 | g_free(default_priority_str); |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
239 | default_priority_str = g_strdup(prio_str); |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
240 | } else |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
241 | g_hash_table_insert(host_priorities, g_strdup(host), |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
242 | g_strdup(prio_str)); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
243 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
244 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
245 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
246 | |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
247 | if (default_priority_str) { |
|
36154
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
248 | /* Note: If the string is invalid then this call will fail and |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
249 | we'll try again with our default priority string later. */ |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
250 | set_cipher_priorities(&default_priority, default_priority_str); |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
251 | g_free(default_priority_str); |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
252 | } |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
253 | |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
254 | g_strfreev(entries); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
255 | #endif /* HAVE_GNUTLS_PRIORITY_FUNCS */ |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
256 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
257 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
258 | #ifdef HAVE_GNUTLS_PRIORITY_FUNCS |
|
36154
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
259 | /* Set a default priority string if we didn't do it above */ |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
260 | if (!default_priority) { |
|
36155
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
261 | if (gnutls_check_version("3.2.2")) { |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
262 | set_cipher_priorities(&default_priority, GNUTLS_DEFAULT_PRIORITY); |
|
76a2a6d75768
Specify a different set of encryption ciphers for TLS connections when
Mark Doliner <mark@kingant.net>
parents:
36154
diff
changeset
|
263 | } |
|
36154
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
264 | if (!default_priority) { |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
265 | /* Try again with an extremely simple priority string. */ |
|
add4a21c473a
Add a wrapper function around gnutls_priority_init().
Mark Doliner <mark@kingant.net>
parents:
36153
diff
changeset
|
266 | set_cipher_priorities(&default_priority, "NORMAL"); |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
267 | } |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
268 | } |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
269 | #endif /* HAVE_GNUTLS_PRIORITY_FUNCS */ |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
270 | |
| 7016 | 271 | gnutls_global_init(); |
| 272 | ||
| 273 | gnutls_certificate_allocate_credentials(&xcred); | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
274 | |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
275 | /* TODO: I can likely remove this */ |
|
17430
95d550efcc3d
disapproval of revision '8976f9e287fef5bd2856c34ea931afa70a997895'
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17429
diff
changeset
|
276 | gnutls_certificate_set_x509_trust_file(xcred, "ca.pem", |
|
95d550efcc3d
disapproval of revision '8976f9e287fef5bd2856c34ea931afa70a997895'
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17429
diff
changeset
|
277 | GNUTLS_X509_FMT_PEM); |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
278 | } |
| 7016 | 279 | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
280 | static gboolean |
|
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
281 | ssl_gnutls_init(void) |
|
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
282 | { |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
283 | return TRUE; |
| 7016 | 284 | } |
| 285 | ||
| 286 | static void | |
| 287 | ssl_gnutls_uninit(void) | |
| 288 | { | |
| 289 | gnutls_global_deinit(); | |
| 290 | ||
| 291 | gnutls_certificate_free_credentials(xcred); | |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
292 | xcred = NULL; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
293 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
294 | #ifdef HAVE_GNUTLS_PRIORITY_FUNCS |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
295 | if (host_priorities) { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
296 | g_hash_table_destroy(host_priorities); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
297 | host_priorities = NULL; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
298 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
299 | |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
300 | gnutls_priority_deinit(default_priority); |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
301 | default_priority = NULL; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
302 | #endif |
| 7016 | 303 | } |
| 304 | ||
|
18475
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
305 | static void |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
306 | ssl_gnutls_verified_cb(PurpleCertificateVerificationStatus st, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
307 | gpointer userdata) |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
308 | { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
309 | PurpleSslConnection *gsc = (PurpleSslConnection *) userdata; |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
310 | |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
311 | if (st == PURPLE_CERTIFICATE_VALID) { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
312 | /* Certificate valid? Good! Do the connection! */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
313 | 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
|
314 | } else { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
315 | /* Otherwise, signal an error */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
316 | if(gsc->error_cb != NULL) |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
317 | gsc->error_cb(gsc, PURPLE_SSL_CERTIFICATE_INVALID, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
318 | gsc->connect_cb_data); |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
319 | purple_ssl_close(gsc); |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
320 | } |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
321 | } |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
322 | |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
323 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
324 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
325 | static void ssl_gnutls_handshake_cb(gpointer data, gint source, |
| 15884 | 326 | PurpleInputCondition cond) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
327 | { |
| 15884 | 328 | PurpleSslConnection *gsc = data; |
| 329 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
330 | ssize_t ret; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
331 | |
|
20151
0b5ba1105191
applied changes from 5252885d793a4d288d92856d511d721bf5bb87ef
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
332 | /*purple_debug_info("gnutls", "Handshaking with %s\n", gsc->host);*/ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
333 | ret = gnutls_handshake(gnutls_data->session); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
334 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
335 | if(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
336 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
337 | |
| 15884 | 338 | purple_input_remove(gnutls_data->handshake_handler); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
339 | gnutls_data->handshake_handler = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
340 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
341 | if(ret != 0) { |
|
36153
e607a97ef213
Better indentation and debug message.
Mark Doliner <mark@kingant.net>
parents:
36150
diff
changeset
|
342 | purple_debug_error("gnutls", "Handshake failed: %s\n", |
|
e607a97ef213
Better indentation and debug message.
Mark Doliner <mark@kingant.net>
parents:
36150
diff
changeset
|
343 | gnutls_strerror(ret)); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
344 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
345 | if(gsc->error_cb != NULL) |
| 15884 | 346 | gsc->error_cb(gsc, PURPLE_SSL_HANDSHAKE_FAILED, |
|
36153
e607a97ef213
Better indentation and debug message.
Mark Doliner <mark@kingant.net>
parents:
36150
diff
changeset
|
347 | gsc->connect_cb_data); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
348 | |
| 15884 | 349 | purple_ssl_close(gsc); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
350 | } else { |
|
18458
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
351 | /* Now we are cooking with gas! */ |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
352 | PurpleSslOps *ops = purple_ssl_get_ops(); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
353 | 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
|
354 | |
|
18458
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
355 | PurpleCertificateScheme *x509 = |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
356 | purple_certificate_find_scheme("x509"); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
357 | |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
358 | GList * l; |
|
19711
19b0780efe0e
Fix compiler warnings about having a variable declaration after some
Mark Doliner <markdoliner@pidgin.im>
parents:
19501
diff
changeset
|
359 | |
|
19b0780efe0e
Fix compiler warnings about having a variable declaration after some
Mark Doliner <markdoliner@pidgin.im>
parents:
19501
diff
changeset
|
360 | /* 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
|
361 | 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
|
362 | |
|
18458
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
363 | for (l=peers; l; l = l->next) { |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
364 | PurpleCertificate *crt = l->data; |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
365 | GByteArray *z = |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
366 | x509->get_fingerprint_sha1(crt); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
367 | gchar * fpr = |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
368 | purple_base16_encode_chunked(z->data, |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
369 | z->len); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
370 | |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
371 | purple_debug_info("gnutls/x509", |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
372 | "Key print: %s\n", |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
373 | fpr); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
374 | |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
375 | /* Kill the cert! */ |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
376 | 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
|
377 | |
|
18458
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
378 | g_free(fpr); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
379 | g_byte_array_free(z, TRUE); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
380 | } |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
381 | 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
|
382 | |
|
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
|
383 | { |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
384 | const gnutls_datum_t *cert_list; |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34302
diff
changeset
|
385 | guint cert_list_size = 0; |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
386 | gnutls_session_t session=gnutls_data->session; |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
36191
diff
changeset
|
387 | guint i; |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
388 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
389 | cert_list = |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
390 | 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
|
391 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
392 | 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
|
393 | "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
|
394 | cert_list_size); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
395 | 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
|
396 | { |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
397 | 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
|
398 | 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
|
399 | 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
|
400 | gchar tbuf[256]; |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
401 | 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
|
402 | gchar * tasc = NULL; |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
403 | gnutls_x509_crt_t cert; |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
404 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
405 | 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
|
406 | 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
|
407 | 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
|
408 | |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
409 | gnutls_x509_crt_get_fingerprint(cert, GNUTLS_DIG_SHA, |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
410 | 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
|
411 | |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
412 | fpr_asc = |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
413 | 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
|
414 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
415 | 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
|
416 | "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
|
417 | i, fpr_asc); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
418 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
419 | tsz=sizeof(tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
420 | 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
|
421 | 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
|
422 | 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
|
423 | "Serial: %s\n", |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
424 | tasc); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
425 | 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
|
426 | |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
427 | tsz=sizeof(tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
428 | 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
|
429 | 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
|
430 | "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
|
431 | tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
432 | tsz=sizeof(tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
433 | 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
|
434 | 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
|
435 | "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
|
436 | tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
437 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
438 | 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
|
439 | fpr_asc = NULL; |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
440 | 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
|
441 | } |
|
17430
95d550efcc3d
disapproval of revision '8976f9e287fef5bd2856c34ea931afa70a997895'
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17429
diff
changeset
|
442 | } |
|
18475
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
443 | |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
444 | /* 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
|
445 | /* 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
|
446 | if (gsc->verifier) { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
447 | GList *peers; |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
448 | /* First, get the peer cert chain */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
449 | peers = purple_ssl_get_peer_certificates(gsc); |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
450 | |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
451 | /* Now kick off the verification process */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
452 | purple_certificate_verify(gsc->verifier, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
453 | gsc->host, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
454 | peers, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
455 | ssl_gnutls_verified_cb, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
456 | gsc); |
|
18656
02c822b398d2
- purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18654
diff
changeset
|
457 | |
|
02c822b398d2
- purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18654
diff
changeset
|
458 | purple_certificate_destroy_list(peers); |
|
18475
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
459 | } else { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
460 | /* Otherwise, just call the "connection complete" |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
461 | callback */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
462 | 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
|
463 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
464 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
465 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
466 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
467 | |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
468 | static gboolean |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
469 | start_handshake_cb(gpointer data) |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
470 | { |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
471 | PurpleSslConnection *gsc = data; |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
472 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
473 | |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
474 | purple_debug_info("gnutls", "Starting handshake with %s\n", gsc->host); |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
475 | |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
476 | gnutls_data->handshake_timer = 0; |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
477 | |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
478 | ssl_gnutls_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ); |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
479 | return FALSE; |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
480 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
481 | |
| 7016 | 482 | static void |
| 15884 | 483 | ssl_gnutls_connect(PurpleSslConnection *gsc) |
| 7016 | 484 | { |
| 15884 | 485 | PurpleSslGnutlsData *gnutls_data; |
| 7016 | 486 | |
| 15884 | 487 | gnutls_data = g_new0(PurpleSslGnutlsData, 1); |
| 7016 | 488 | gsc->private_data = gnutls_data; |
| 489 | ||
| 490 | 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
|
491 | #ifdef HAVE_GNUTLS_PRIORITY_FUNCS |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
492 | { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
493 | const char *prio_str = NULL; |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
494 | gboolean set = FALSE; |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
495 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
496 | /* Let's see if someone has specified a specific priority */ |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
497 | if (gsc->host && host_priorities) |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
498 | prio_str = g_hash_table_lookup(host_priorities, gsc->host); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
499 | |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
500 | if (prio_str) |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
501 | set = (GNUTLS_E_SUCCESS == |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
502 | gnutls_priority_set_direct(gnutls_data->session, prio_str, |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
503 | NULL)); |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
504 | |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
505 | if (!set) |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
506 | gnutls_priority_set(gnutls_data->session, default_priority); |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
507 | } |
|
25643
04831cc56f5a
Use _set_default_priority on gnutls versions lacking _priority_set_direct.
Ethan Blanton <elb@pidgin.im>
parents:
25642
diff
changeset
|
508 | #else |
|
04831cc56f5a
Use _set_default_priority on gnutls versions lacking _priority_set_direct.
Ethan Blanton <elb@pidgin.im>
parents:
25642
diff
changeset
|
509 | 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
|
510 | #endif |
| 7016 | 511 | |
|
35382
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35024
diff
changeset
|
512 | if (gsc->host) { |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35024
diff
changeset
|
513 | gnutls_server_name_set(gnutls_data->session, GNUTLS_NAME_DNS, |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35024
diff
changeset
|
514 | gsc->host, strlen(gsc->host)); |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35024
diff
changeset
|
515 | } |
| 7016 | 516 | |
| 517 | gnutls_credentials_set(gnutls_data->session, GNUTLS_CRD_CERTIFICATE, | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
518 | xcred); |
| 7016 | 519 | |
|
14223
c6ba4f3482de
[gaim-migrate @ 16809]
Mark Doliner <markdoliner@pidgin.im>
parents:
13985
diff
changeset
|
520 | gnutls_transport_set_ptr(gnutls_data->session, GINT_TO_POINTER(gsc->fd)); |
| 7016 | 521 | |
| 15884 | 522 | gnutls_data->handshake_handler = purple_input_add(gsc->fd, |
| 523 | PURPLE_INPUT_READ, ssl_gnutls_handshake_cb, gsc); | |
| 7016 | 524 | |
|
17345
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
525 | /* Orborde asks: Why are we configuring a callback, then |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
526 | (almost) immediately calling it? |
|
17345
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
527 | |
|
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
528 | 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
|
529 | 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
|
530 | 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
|
531 | the callback. |
|
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
532 | |
|
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
533 | 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
|
534 | 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
|
535 | accomplish this. |
|
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
536 | */ |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
537 | gnutls_data->handshake_timer = purple_timeout_add(0, start_handshake_cb, |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
538 | gsc); |
| 7016 | 539 | } |
| 540 | ||
| 541 | static void | |
| 15884 | 542 | ssl_gnutls_close(PurpleSslConnection *gsc) |
| 7016 | 543 | { |
| 15884 | 544 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
| 7016 | 545 | |
| 7467 | 546 | if(!gnutls_data) |
| 547 | return; | |
| 548 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
549 | if(gnutls_data->handshake_handler) |
| 15884 | 550 | purple_input_remove(gnutls_data->handshake_handler); |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
551 | if (gnutls_data->handshake_timer) |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
552 | purple_timeout_remove(gnutls_data->handshake_timer); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
553 | |
| 7016 | 554 | gnutls_bye(gnutls_data->session, GNUTLS_SHUT_RDWR); |
| 555 | ||
| 556 | gnutls_deinit(gnutls_data->session); | |
| 557 | ||
| 558 | g_free(gnutls_data); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
559 | gsc->private_data = NULL; |
| 7016 | 560 | } |
| 561 | ||
| 562 | static size_t | |
| 15884 | 563 | ssl_gnutls_read(PurpleSslConnection *gsc, void *data, size_t len) |
| 7016 | 564 | { |
| 15884 | 565 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
566 | ssize_t s; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
567 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
568 | s = gnutls_record_recv(gnutls_data->session, data, len); |
| 7016 | 569 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
570 | if(s == GNUTLS_E_AGAIN || s == GNUTLS_E_INTERRUPTED) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
571 | s = -1; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
572 | errno = EAGAIN; |
|
36146
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
573 | |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
574 | #ifdef GNUTLS_E_PREMATURE_TERMINATION |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
575 | } else if (s == GNUTLS_E_PREMATURE_TERMINATION) { |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
576 | purple_debug_warning("gnutls", "Received a FIN on the TCP socket " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
577 | "for %s. This either means that the remote server closed " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
578 | "the socket without sending us a Close Notify alert or a " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
579 | "man-in-the-middle injected a FIN into the TCP stream. " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
580 | "Assuming it's the former.\n", gsc->host); |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
581 | #else |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
582 | } else if (s == GNUTLS_E_UNEXPECTED_PACKET_LENGTH) { |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
583 | purple_debug_warning("gnutls", "Received packet of unexpected " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
584 | "length on the TCP socket for %s. Among other " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
585 | "possibilities this might mean that the remote server " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
586 | "closed the socket without sending us a Close Notify alert. " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
587 | "Assuming that's the case for compatibility, however, note " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
588 | "that it's quite possible that we're incorrectly ignoing " |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
589 | "a real error.\n", gsc->host); |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
590 | #endif |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
591 | /* |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
592 | * Summary: |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
593 | * Always treat a closed TCP connection as if the remote server cleanly |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
594 | * terminated the SSL session. |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
595 | * |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
596 | * Background: |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
597 | * Most TLS servers send a Close Notify alert before sending TCP FIN |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
598 | * when closing a session. This informs us at the TLS layer that the |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
599 | * connection is being cleanly closed. Without this it's more |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
600 | * difficult for us to determine whether the session was closed |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
601 | * cleanly (we would need to resort to having the application layer |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
602 | * perform this check, e.g. by looking at the Content-Length HTTP |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
603 | * header for HTTP connections). |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
604 | * |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
605 | * There ARE servers that don't send Close Notify and we want to be |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
606 | * compatible with them. And so we don't require Close Notify. This |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
607 | * seems to match the behavior of libnss. This is a slightly |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
608 | * unfortunate situation. It means a malicious MITM can inject a FIN |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
609 | * into our TCP stream and cause our encrypted session to termiate |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
610 | * and we won't indicate any problem to the user. |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
611 | * |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
612 | * GnuTLS < 3.0.0 returned the UNEXPECTED_PACKET_LENGTH error on EOF. |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
613 | * GnuTLS >= 3.0.0 added the PREMATURE_TERMINATION error to allow us |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
614 | * to detect the problem more specifically. |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
615 | * |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
616 | * For historical discussion see: |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
617 | * https://developer.pidgin.im/ticket/16172 |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
618 | * http://trac.adiumx.com/intertrac/ticket%3A16678 |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
619 | * https://bugzilla.mozilla.org/show_bug.cgi?id=508698#c4 |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
620 | * http://lists.gnu.org/archive/html/gnutls-devel/2008-03/msg00058.html |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
621 | * Or search for GNUTLS_E_UNEXPECTED_PACKET_LENGTH or |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
622 | * GNUTLS_E_PREMATURE_TERMINATION |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
623 | */ |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
624 | s = 0; |
|
42ba908c25c7
Fix Yahoo login when using the GnuTLS library for TLS connections.
Mark Doliner <mark@kingant.net>
parents:
35978
diff
changeset
|
625 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
626 | } else if(s < 0) { |
| 15884 | 627 | 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
|
628 | gnutls_strerror(s)); |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
629 | s = -1; |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
630 | /* |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
631 | * 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
|
632 | * 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
|
633 | * 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
|
634 | * that returns the error message. |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
635 | */ |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
636 | errno = EIO; |
| 7834 | 637 | } |
| 7016 | 638 | |
| 639 | return s; | |
| 640 | } | |
| 641 | ||
| 642 | static size_t | |
| 15884 | 643 | ssl_gnutls_write(PurpleSslConnection *gsc, const void *data, size_t len) |
| 7016 | 644 | { |
| 15884 | 645 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
646 | ssize_t s = 0; |
| 7016 | 647 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
648 | /* XXX: when will gnutls_data be NULL? */ |
| 7467 | 649 | if(gnutls_data) |
| 650 | s = gnutls_record_send(gnutls_data->session, data, len); | |
| 7016 | 651 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
652 | if(s == GNUTLS_E_AGAIN || s == GNUTLS_E_INTERRUPTED) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
653 | s = -1; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
654 | errno = EAGAIN; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
655 | } else if(s < 0) { |
| 15884 | 656 | 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
|
657 | gnutls_strerror(s)); |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
658 | s = -1; |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
659 | /* |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
660 | * 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
|
661 | * 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
|
662 | * 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
|
663 | * that returns the error message. |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
664 | */ |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
665 | errno = EIO; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
666 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
667 | |
| 7016 | 668 | return s; |
| 669 | } | |
| 670 | ||
|
19494
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
671 | /* Forward declarations are fun! */ |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
672 | static PurpleCertificate * |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
673 | x509_import_from_datum(const gnutls_datum_t dt, gnutls_x509_crt_fmt_t mode); |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
674 | /* indeed! */ |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
675 | static gboolean |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
676 | x509_certificate_signed_by(PurpleCertificate * crt, |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
677 | PurpleCertificate * issuer); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
678 | static void |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
679 | x509_destroy_certificate(PurpleCertificate * crt); |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
680 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
681 | static GList * |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
682 | ssl_gnutls_get_peer_certificates(PurpleSslConnection * gsc) |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
683 | { |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
684 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
685 | PurpleCertificate *prvcrt = NULL; |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
686 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
687 | /* List of Certificate instances to return */ |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
688 | GList * peer_certs = NULL; |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
689 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
690 | /* List of raw certificates as given by GnuTLS */ |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
691 | const gnutls_datum_t *cert_list; |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
692 | unsigned int cert_list_size = 0; |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
693 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
694 | 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
|
695 | |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
696 | /* This should never, ever happen. */ |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
697 | 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
|
698 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
699 | /* Get the certificate list from GnuTLS */ |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
700 | /* 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
|
701 | 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
|
702 | &cert_list_size); |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
703 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
704 | /* 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
|
705 | for (i = 0; i < cert_list_size; i++) { |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
706 | 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
|
707 | GNUTLS_X509_FMT_DER); |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
708 | /* 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
|
709 | 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
|
710 | TODO: Is anyone complaining? (Maybe elb?) */ |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
711 | /* only append if previous cert was actually signed by this one. |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
712 | * Thanks Microsoft. */ |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
713 | if ((prvcrt == NULL) || x509_certificate_signed_by(prvcrt, newcrt)) { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
714 | peer_certs = g_list_append(peer_certs, newcrt); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
715 | prvcrt = newcrt; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
716 | } else { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
717 | x509_destroy_certificate(newcrt); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
718 | purple_debug_error("gnutls", "Dropping further peer certificates " |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
719 | "because the chain is broken!\n"); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
720 | break; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29942
diff
changeset
|
721 | } |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
722 | } |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
723 | |
|
19494
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
724 | /* cert_list doesn't need free()-ing */ |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
725 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
726 | return peer_certs; |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
727 | } |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
728 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
729 | /************************************************************************/ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
730 | /* X.509 functionality */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
731 | /************************************************************************/ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
732 | const gchar * SCHEME_NAME = "x509"; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
733 | |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
734 | static PurpleCertificateScheme x509_gnutls; |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
735 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
736 | /** 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
|
737 | typedef struct { |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
738 | gint refcount; |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
739 | gnutls_x509_crt_t crt; |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
740 | } x509_crtdata_t; |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
741 | |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
742 | /** 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
|
743 | static x509_crtdata_t * |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
744 | 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
|
745 | { |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
746 | (cd->refcount)++; |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
747 | return cd; |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
748 | } |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
749 | |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
750 | static void |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
751 | 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
|
752 | { |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
753 | (cd->refcount)--; |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
754 | |
|
19714
b424012723a8
refcount of 0 is normal
Mark Doliner <markdoliner@pidgin.im>
parents:
19713
diff
changeset
|
755 | 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
|
756 | 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
|
757 | "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
|
758 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
759 | /* 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
|
760 | 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
|
761 | /* Kill the internal data */ |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
762 | 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
|
763 | /* And kill the struct */ |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
764 | g_free( cd ); |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
765 | } |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
766 | } |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
767 | |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
768 | /** 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
|
769 | #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
|
770 | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
771 | /** Transforms a gnutls_datum_t 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
|
772 | * |
|
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
|
773 | * @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
|
774 | * @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
|
775 | * 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
|
776 | * "over the wire" certs for SSL) |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
777 | * |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
778 | * @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
|
779 | */ |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
780 | static PurpleCertificate * |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
781 | x509_import_from_datum(const gnutls_datum_t dt, gnutls_x509_crt_fmt_t mode) |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
782 | { |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
783 | /* 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
|
784 | x509_crtdata_t *certdat; |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
785 | /* New certificate to return */ |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
786 | PurpleCertificate * crt; |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
787 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
788 | /* 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
|
789 | 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
|
790 | 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
|
791 | 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
|
792 | |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
793 | /* 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
|
794 | /* 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
|
795 | 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
|
796 | |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
797 | /* 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
|
798 | crt = g_new0(PurpleCertificate, 1); |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
799 | 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
|
800 | crt->data = x509_crtdata_addref(certdat); |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
801 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
802 | return crt; |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
803 | } |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
804 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
805 | /** 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
|
806 | * @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
|
807 | * |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
808 | * @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
|
809 | */ |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
810 | static PurpleCertificate * |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
811 | 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
|
812 | { |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
813 | PurpleCertificate *crt; /* Certificate being constructed */ |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
814 | 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
|
815 | gsize buf_sz; /* Size of the above */ |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
816 | gnutls_datum_t 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
|
817 | |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
818 | purple_debug_info("gnutls", |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
819 | "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
|
820 | filename); |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
821 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
822 | /* 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
|
823 | into memory */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
824 | /* TODO: Should I worry about very large files here? */ |
|
19494
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
825 | g_return_val_if_fail( |
|
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
826 | g_file_get_contents(filename, |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
827 | &buf, |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
828 | &buf_sz, |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
829 | NULL /* No error checking for now */ |
|
19494
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
830 | ), |
|
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
831 | NULL); |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
832 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
833 | /* Load the datum struct */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
834 | dt.data = (unsigned char *) buf; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
835 | dt.size = buf_sz; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
836 | |
|
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
|
837 | /* 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
|
838 | 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
|
839 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
840 | /* Cleanup */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
841 | g_free(buf); |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
842 | |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
843 | return crt; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
844 | } |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
845 | |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
846 | /** Imports a number of PEM-formatted X.509 certificates from the specified file. |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
847 | * @param filename Filename to import from. Format is PEM |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
848 | * |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
849 | * @return A newly allocated GSList of Certificate structures of the x509_gnutls scheme |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
850 | */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
851 | static GSList * |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
852 | x509_importcerts_from_file(const gchar * filename) |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
853 | { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
854 | PurpleCertificate *crt; /* Certificate being constructed */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
855 | gchar *buf; /* Used to load the raw file data */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
856 | gchar *begin, *end; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
857 | GSList *crts = NULL; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
858 | gsize buf_sz; /* Size of the above */ |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
859 | gnutls_datum_t dt; /* Struct to pass down to GnuTLS */ |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
860 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
861 | purple_debug_info("gnutls", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
862 | "Attempting to load X.509 certificates from %s\n", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
863 | filename); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
864 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
865 | /* Next, we'll simply yank the entire contents of the file |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
866 | into memory */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
867 | /* TODO: Should I worry about very large files here? */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
868 | g_return_val_if_fail( |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
869 | g_file_get_contents(filename, |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
870 | &buf, |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
871 | &buf_sz, |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
872 | NULL /* No error checking for now */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
873 | ), |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
874 | NULL); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
875 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
876 | begin = buf; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
877 | while((end = strstr(begin, "-----END CERTIFICATE-----")) != NULL) { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
878 | end += sizeof("-----END CERTIFICATE-----")-1; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
879 | /* Load the datum struct */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
880 | dt.data = (unsigned char *) begin; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
881 | dt.size = (end-begin); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
882 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
883 | /* Perform the conversion; files should be in PEM format */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
884 | crt = x509_import_from_datum(dt, GNUTLS_X509_FMT_PEM); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
885 | crts = g_slist_prepend(crts, crt); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
886 | begin = end; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
887 | } |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
888 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
889 | /* Cleanup */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
890 | g_free(buf); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
891 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
892 | return crts; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
893 | } |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
894 | |
|
18496
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
895 | /** |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
896 | * 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
|
897 | * @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
|
898 | * @param crt Certificate to export |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
899 | * |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
900 | * @return TRUE if success, otherwise FALSE |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
901 | */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
902 | static gboolean |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
903 | 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
|
904 | { |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
905 | gnutls_x509_crt_t crt_dat; /* GnuTLS cert struct */ |
|
18496
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
906 | int ret; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
907 | gchar * out_buf; /* Data to output */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
908 | size_t out_size; /* Output size */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
909 | gboolean success = FALSE; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
910 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
911 | /* Paranoia paranoia paranoia! */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
912 | 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
|
913 | 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
|
914 | 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
|
915 | 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
|
916 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
917 | 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
|
918 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
919 | /* Obtain the output size required */ |
|
18593
9d2bd532bf74
- Fix intermittent crash due to uninitialized variable
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18592
diff
changeset
|
920 | out_size = 0; |
|
18496
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
921 | 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
|
922 | NULL, /* Provide no buffer yet */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
923 | &out_size /* Put size here */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
924 | ); |
|
18591
9d7c99e312b9
- Fix an incorrect assertion in GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18496
diff
changeset
|
925 | 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
|
926 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
927 | /* 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
|
928 | 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
|
929 | 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
|
930 | 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
|
931 | &out_size /* Put size here */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
932 | ); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
933 | if (ret != 0) { |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
934 | purple_debug_error("gnutls/x509", |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
935 | "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
|
936 | ret); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
937 | g_free(out_buf); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
938 | return FALSE; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
939 | } |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
940 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
941 | /* 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
|
942 | 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
|
943 | out_buf, out_size); |
|
18496
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
944 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
945 | g_free(out_buf); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
946 | return success; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
947 | } |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
948 | |
|
18654
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
949 | static PurpleCertificate * |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
950 | x509_copy_certificate(PurpleCertificate *crt) |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
951 | { |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
952 | x509_crtdata_t *crtdat; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
953 | PurpleCertificate *newcrt; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
954 | |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
955 | g_return_val_if_fail(crt, NULL); |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
956 | 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
|
957 | |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
958 | crtdat = (x509_crtdata_t *) crt->data; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
959 | |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
960 | newcrt = g_new0(PurpleCertificate, 1); |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
961 | newcrt->scheme = &x509_gnutls; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
962 | newcrt->data = x509_crtdata_addref(crtdat); |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
963 | |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
964 | return newcrt; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
965 | } |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
966 | /** Frees a Certificate |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
967 | * |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
968 | * 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
|
969 | * given. |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
970 | * @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
|
971 | * 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
|
972 | * |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
973 | */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
974 | static void |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
975 | x509_destroy_certificate(PurpleCertificate * crt) |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
976 | { |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
977 | if (NULL == crt) return; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
978 | |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
979 | /* 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
|
980 | if ( crt->scheme != &x509_gnutls ) { |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
981 | purple_debug_error("gnutls", |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
982 | "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
|
983 | crt->scheme->name, |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
984 | SCHEME_NAME); |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
985 | return; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
986 | } |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
987 | |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
988 | 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
|
989 | 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
|
990 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
991 | /* 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
|
992 | underlying data */ |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
993 | 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
|
994 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
995 | /* Kill the structure itself */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
996 | g_free(crt); |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
997 | } |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
998 | |
|
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
|
999 | /** 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
|
1000 | * |
|
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
|
1001 | * @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
|
1002 | * @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
|
1003 | * |
|
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
|
1004 | * @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
|
1005 | * @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
|
1006 | */ |
|
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
|
1007 | 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
|
1008 | 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
|
1009 | 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
|
1010 | { |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
1011 | gnutls_x509_crt_t crt_dat; |
|
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
1012 | gnutls_x509_crt_t issuer_dat; |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1013 | 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
|
1014 | int ret; |
|
27917
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1015 | gchar *crt_id = NULL; |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1016 | gchar *issuer_id = NULL; |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
1017 | |
|
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
|
1018 | 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
|
1019 | 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
|
1020 | |
|
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
|
1021 | /* 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
|
1022 | 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
|
1023 | 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
|
1024 | |
|
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
|
1025 | /* 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
|
1026 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
1027 | 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
|
1028 | 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
|
1029 | |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1030 | /* Ensure crt issuer matches the name on the issuer cert. */ |
|
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
|
1031 | 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
|
1032 | 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
|
1033 | |
|
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
|
1034 | 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
|
1035 | 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
|
1036 | "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
|
1037 | ret); |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1038 | } else { |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1039 | gchar *crt_id, *issuer_id, *crt_issuer_id; |
|
36213
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
1040 | crt_id = x509_cert_dn(crt); |
|
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
1041 | issuer_id = x509_cert_dn(issuer); |
|
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
1042 | crt_issuer_id = x509_issuer_dn(crt); |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1043 | purple_debug_info("gnutls/x509", |
|
28655
69e23620d813
ssl-gnutls: I think this error message makes a little more sense.
Paul Aurich <darkrain42@pidgin.im>
parents:
28652
diff
changeset
|
1044 | "Certificate %s is issued by " |
|
69e23620d813
ssl-gnutls: I think this error message makes a little more sense.
Paul Aurich <darkrain42@pidgin.im>
parents:
28652
diff
changeset
|
1045 | "%s, which does not match %s.\n", |
|
20177
92af9f603b75
applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@pidgin.im>
parents:
20176
diff
changeset
|
1046 | crt_id ? crt_id : "(null)", |
|
92af9f603b75
applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@pidgin.im>
parents:
20176
diff
changeset
|
1047 | crt_issuer_id ? crt_issuer_id : "(null)", |
|
92af9f603b75
applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@pidgin.im>
parents:
20176
diff
changeset
|
1048 | 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
|
1049 | g_free(crt_id); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1050 | g_free(issuer_id); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1051 | 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
|
1052 | } |
|
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
|
1053 | |
|
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
|
1054 | /* 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
|
1055 | 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
|
1056 | } |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
1057 | |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1058 | /* Check basic constraints extension (if it exists then the CA flag must |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1059 | be set to true, and it must exist for certs with version 3 or higher. */ |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1060 | ret = gnutls_x509_crt_get_basic_constraints(issuer_dat, NULL, NULL, NULL); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1061 | if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1062 | if (gnutls_x509_crt_get_version(issuer_dat) >= 3) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1063 | /* Reject cert (no basic constraints and cert version is >= 3). */ |
|
36213
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
1064 | gchar *issuer_id = x509_cert_dn(issuer); |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1065 | purple_debug_info("gnutls/x509", "Rejecting cert because the " |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1066 | "basic constraints extension is missing from issuer cert " |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1067 | "for %s. The basic constraints extension is required on " |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1068 | "all version 3 or higher certs (this cert is version %d).", |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1069 | issuer_id ? issuer_id : "(null)", |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1070 | gnutls_x509_crt_get_version(issuer_dat)); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1071 | g_free(issuer_id); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1072 | return FALSE; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1073 | } else { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1074 | /* Allow cert (no basic constraints and cert version is < 3). */ |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1075 | purple_debug_info("gnutls/x509", "Basic constraint extension is " |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1076 | "missing from issuer cert for %s. Allowing this because " |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1077 | "the cert is version %d and the basic constraints " |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1078 | "extension is only required for version 3 or higher " |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1079 | "certs.", issuer_id ? issuer_id : "(null)", |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1080 | gnutls_x509_crt_get_version(issuer_dat)); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1081 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1082 | } else if (ret <= 0) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1083 | /* Reject cert (CA flag is false in basic constraints). */ |
|
36213
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
1084 | gchar *issuer_id = x509_cert_dn(issuer); |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1085 | purple_debug_info("gnutls/x509", "Rejecting cert because the CA flag " |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1086 | "is set to false in the basic constraints extension for " |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1087 | "issuer cert %s. ret=%d\n", |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1088 | issuer_id ? issuer_id : "(null)", ret); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1089 | g_free(issuer_id); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1090 | return FALSE; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1091 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36146
diff
changeset
|
1092 | |
|
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
|
1093 | /* 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
|
1094 | /* 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
|
1095 | 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
|
1096 | 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
|
1097 | /* 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
|
1098 | (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
|
1099 | 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
|
1100 | 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
|
1101 | 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
|
1102 | &verify); |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
1103 | |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1104 | 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
|
1105 | 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
|
1106 | "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
|
1107 | 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
|
1108 | } |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1109 | |
|
28652
46da88b82471
Check the GnuTLS version before using a recent-ish flag. Fixes #10412.
Paul Aurich <darkrain42@pidgin.im>
parents:
27917
diff
changeset
|
1110 | #ifdef HAVE_GNUTLS_CERT_INSECURE_ALGORITHM |
|
27917
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1111 | if (verify & GNUTLS_CERT_INSECURE_ALGORITHM) { |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1112 | /* |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1113 | * A certificate in the chain is signed with an insecure |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1114 | * algorithm. Put a warning into the log to make this error |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1115 | * perfectly clear as soon as someone looks at the debug log is |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1116 | * generated. |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1117 | */ |
|
36213
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
1118 | crt_id = x509_cert_dn(crt); |
|
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
1119 | issuer_id = x509_issuer_dn(crt); |
|
27917
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1120 | purple_debug_warning("gnutls/x509", |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1121 | "Insecure hash algorithm used by %s to sign %s\n", |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1122 | issuer_id, crt_id); |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1123 | } |
|
28652
46da88b82471
Check the GnuTLS version before using a recent-ish flag. Fixes #10412.
Paul Aurich <darkrain42@pidgin.im>
parents:
27917
diff
changeset
|
1124 | #endif |
|
27917
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1125 | |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1126 | 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
|
1127 | /* 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
|
1128 | there were no errors*/ |
|
27917
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1129 | if (!crt_id) |
|
36213
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
1130 | crt_id = x509_cert_dn(crt); |
|
27917
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1131 | if (!issuer_id) |
|
36213
f47eb0bc58c9
Minor gnutls cert cleanup.
Mark Doliner <mark@kingant.net>
parents:
36211
diff
changeset
|
1132 | issuer_id = x509_issuer_dn(crt); |
|
27917
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1133 | purple_debug_error("gnutls/x509", |
|
e52e7ddb0cb2
Add a debug log message when MD5 is used in a verification chain. Refs #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27407
diff
changeset
|
1134 | "Bad signature from %s on %s\n", |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1135 | issuer_id, crt_id); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1136 | g_free(crt_id); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1137 | 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
|
1138 | |
|
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
|
1139 | 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
|
1140 | } /* 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
|
1141 | |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
1142 | /* 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
|
1143 | 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
|
1144 | } |
|
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
|
1145 | |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1146 | static GByteArray * |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1147 | x509_sha1sum(PurpleCertificate *crt) |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1148 | { |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1149 | size_t hashlen = 20; /* SHA1 hashes are 20 bytes */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1150 | size_t tmpsz = hashlen; /* Throw-away variable for GnuTLS to stomp on*/ |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
1151 | gnutls_x509_crt_t crt_dat; |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1152 | GByteArray *hash; /**< Final hash container */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1153 | guchar hashbuf[hashlen]; /**< Temporary buffer to contain hash */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1154 | |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1155 | g_return_val_if_fail(crt, NULL); |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1156 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
1157 | crt_dat = X509_GET_GNUTLS_DATA(crt); |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1158 | |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1159 | /* Extract the fingerprint */ |
|
19495
af7b321844ab
- More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19494
diff
changeset
|
1160 | g_return_val_if_fail( |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
1161 | 0 == gnutls_x509_crt_get_fingerprint(crt_dat, GNUTLS_DIG_SHA, |
|
19495
af7b321844ab
- More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19494
diff
changeset
|
1162 | hashbuf, &tmpsz), |
|
af7b321844ab
- More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19494
diff
changeset
|
1163 | NULL); |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1164 | |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1165 | /* This shouldn't happen */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1166 | 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
|
1167 | |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1168 | /* Okay, now create and fill hash array */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1169 | hash = g_byte_array_new(); |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1170 | g_byte_array_append(hash, hashbuf, hashlen); |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1171 | |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1172 | return hash; |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1173 | } |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1174 | |
|
18482
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1175 | static gchar * |
|
19019
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1176 | 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
|
1177 | { |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
1178 | gnutls_x509_crt_t cert_dat; |
|
19019
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1179 | gchar *dn = NULL; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1180 | 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
|
1181 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1182 | 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
|
1183 | 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
|
1184 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1185 | 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
|
1186 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1187 | /* 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
|
1188 | /* 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
|
1189 | space it needs */ |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1190 | dn_size = 0; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1191 | 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
|
1192 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1193 | /* Now allocate and get the Distinguished Name */ |
|
20175
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1194 | /* 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
|
1195 | 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
|
1196 | an extra byte */ |
|
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1197 | dn = g_new0(gchar, ++dn_size); |
|
19496
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1198 | 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
|
1199 | purple_debug_error("gnutls/x509", |
|
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1200 | "Failed to get Distinguished Name\n"); |
|
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1201 | g_free(dn); |
|
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1202 | return NULL; |
|
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1203 | } |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
1204 | |
|
19019
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1205 | return dn; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1206 | } |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1207 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1208 | static gchar * |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1209 | 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
|
1210 | { |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
1211 | gnutls_x509_crt_t cert_dat; |
|
19019
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1212 | gchar *dn = NULL; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1213 | 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
|
1214 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1215 | 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
|
1216 | 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
|
1217 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1218 | 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
|
1219 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1220 | /* 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
|
1221 | /* 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
|
1222 | space it needs */ |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1223 | dn_size = 0; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1224 | 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
|
1225 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1226 | /* Now allocate and get the Distinguished Name */ |
|
20175
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1227 | /* 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
|
1228 | 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
|
1229 | an extra byte */ |
|
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1230 | dn = g_new0(gchar, ++dn_size); |
|
19497
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1231 | 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
|
1232 | purple_debug_error("gnutls/x509", |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1233 | "Failed to get issuer's Distinguished " |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1234 | "Name\n"); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1235 | g_free(dn); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1236 | return NULL; |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1237 | } |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
1238 | |
|
19019
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1239 | return dn; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1240 | } |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1241 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1242 | static gchar * |
|
18482
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1243 | 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
|
1244 | { |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
1245 | gnutls_x509_crt_t cert_dat; |
|
18482
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1246 | gchar *cn = NULL; |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1247 | size_t cn_size; |
|
19497
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1248 | int ret; |
|
18482
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1249 | |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1250 | 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
|
1251 | 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
|
1252 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
1253 | 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
|
1254 | |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1255 | /* 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
|
1256 | /* 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
|
1257 | space it needs */ |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1258 | cn_size = 0; |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1259 | 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
|
1260 | 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
|
1261 | 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
|
1262 | 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
|
1263 | cn, &cn_size); |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1264 | |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1265 | /* Now allocate and get the Common Name */ |
|
20175
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1266 | /* 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
|
1267 | 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
|
1268 | an extra byte */ |
|
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1269 | cn = g_new0(gchar, ++cn_size); |
|
19497
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1270 | ret = gnutls_x509_crt_get_dn_by_oid(cert_dat, |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1271 | GNUTLS_OID_X520_COMMON_NAME, |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1272 | 0, /* First CN found, please */ |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1273 | 0, /* Not in raw mode */ |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1274 | cn, &cn_size); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1275 | if (ret != 0) { |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1276 | purple_debug_error("gnutls/x509", |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1277 | "Failed to get Common Name\n"); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1278 | g_free(cn); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1279 | return NULL; |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1280 | } |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1281 | |
|
18482
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1282 | return cn; |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1283 | } |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1284 | |
|
18643
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1285 | static gboolean |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1286 | 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
|
1287 | { |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
1288 | gnutls_x509_crt_t crt_dat; |
|
18643
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1289 | |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1290 | 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
|
1291 | 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
|
1292 | 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
|
1293 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
1294 | 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
|
1295 | |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1296 | 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
|
1297 | return TRUE; |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1298 | } else { |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1299 | return FALSE; |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1300 | } |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1301 | } |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1302 | |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1303 | static gboolean |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1304 | x509_times (PurpleCertificate *crt, gint64 *activation, gint64 *expiration) |
|
18648
a677b7c8fd97
- Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18643
diff
changeset
|
1305 | { |
|
35978
c0b60f37a7db
Backport warning fixes for libpurple from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31155
diff
changeset
|
1306 | gnutls_x509_crt_t crt_dat; |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1307 | /* 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
|
1308 | const time_t errval = (time_t) (-1); |
|
20224
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1309 | gboolean success = TRUE; |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1310 | |
|
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1311 | 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
|
1312 | 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
|
1313 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
1314 | 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
|
1315 | |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1316 | if (activation) { |
|
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1317 | *activation = gnutls_x509_crt_get_activation_time(crt_dat); |
|
20224
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1318 | if (*activation == errval) |
|
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1319 | success = FALSE; |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1320 | } |
|
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1321 | if (expiration) { |
|
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1322 | *expiration = gnutls_x509_crt_get_expiration_time(crt_dat); |
|
20224
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1323 | if (*expiration == errval) |
|
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1324 | success = FALSE; |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1325 | } |
|
18648
a677b7c8fd97
- Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18643
diff
changeset
|
1326 | |
|
20224
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1327 | return success; |
|
18648
a677b7c8fd97
- Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18643
diff
changeset
|
1328 | } |
|
a677b7c8fd97
- Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18643
diff
changeset
|
1329 | |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1330 | static GByteArray * |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1331 | x509_get_der_data(PurpleCertificate *crt) |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1332 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
1333 | gnutls_x509_crt_t crt_dat; |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1334 | GByteArray *data; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1335 | size_t len; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1336 | int ret; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1337 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1338 | crt_dat = X509_GET_GNUTLS_DATA(crt); |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1339 | g_return_val_if_fail(crt_dat, NULL); |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1340 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1341 | /* Obtain the output size required */ |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1342 | len = 0; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1343 | ret = gnutls_x509_crt_export(crt_dat, GNUTLS_X509_FMT_DER, NULL, &len); |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1344 | g_return_val_if_fail(ret == GNUTLS_E_SHORT_MEMORY_BUFFER, NULL); |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1345 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1346 | /* Now allocate a buffer and *really* export it */ |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1347 | data = g_byte_array_sized_new(len); |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1348 | data->len = len; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1349 | ret = gnutls_x509_crt_export(crt_dat, GNUTLS_X509_FMT_DER, data->data, &len); |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1350 | if (ret != 0) { |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1351 | purple_debug_error("gnutls/x509", |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1352 | "Failed to export cert to buffer with code %d\n", |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1353 | ret); |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1354 | g_byte_array_free(data, TRUE); |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1355 | return NULL; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1356 | } |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1357 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1358 | return data; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1359 | } |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1360 | |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1361 | /* X.509 certificate operations provided by this plugin */ |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1362 | static PurpleCertificateScheme x509_gnutls = { |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1363 | "x509", /* Scheme name */ |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1364 | N_("X.509 Certificates"), /* User-visible scheme name */ |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1365 | 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
|
1366 | x509_export_certificate, /* Certificate export function */ |
|
18654
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
1367 | x509_copy_certificate, /* Copy */ |
|
18454
9a56a88152b9
- Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18450
diff
changeset
|
1368 | x509_destroy_certificate, /* Destroy cert */ |
|
19016
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19007
diff
changeset
|
1369 | x509_certificate_signed_by, /* Signature checker */ |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1370 | 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
|
1371 | 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
|
1372 | 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
|
1373 | x509_common_name, /* Subject name */ |
|
18643
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1374 | x509_check_name, /* Check subject name */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19714
diff
changeset
|
1375 | x509_times, /* Activation/Expiration time */ |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
1376 | x509_importcerts_from_file, /* Multiple certificates import function */ |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1377 | x509_get_der_data, /* Binary DER data */ |
|
36211
de73d2ecffe8
Fix missing initializers warning:
Mark Doliner <mark@kingant.net>
parents:
36200
diff
changeset
|
1378 | NULL, /* register_trusted_tls_cert */ |
|
de73d2ecffe8
Fix missing initializers warning:
Mark Doliner <mark@kingant.net>
parents:
36200
diff
changeset
|
1379 | NULL, /* verify_cert */ |
|
de73d2ecffe8
Fix missing initializers warning:
Mark Doliner <mark@kingant.net>
parents:
36200
diff
changeset
|
1380 | NULL, /* _purple_reserved1 */ |
|
de73d2ecffe8
Fix missing initializers warning:
Mark Doliner <mark@kingant.net>
parents:
36200
diff
changeset
|
1381 | NULL, /* _purple_reserved2 */ |
|
de73d2ecffe8
Fix missing initializers warning:
Mark Doliner <mark@kingant.net>
parents:
36200
diff
changeset
|
1382 | NULL /* _purple_reserved3 */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19714
diff
changeset
|
1383 | |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1384 | }; |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1385 | |
| 15884 | 1386 | static PurpleSslOps ssl_ops = |
| 7016 | 1387 | { |
| 1388 | ssl_gnutls_init, | |
| 1389 | ssl_gnutls_uninit, | |
|
14223
c6ba4f3482de
[gaim-migrate @ 16809]
Mark Doliner <markdoliner@pidgin.im>
parents:
13985
diff
changeset
|
1390 | ssl_gnutls_connect, |
| 7016 | 1391 | ssl_gnutls_close, |
| 1392 | ssl_gnutls_read, | |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1393 | 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
|
1394 | ssl_gnutls_get_peer_certificates, |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1395 | |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1396 | /* padding */ |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1397 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1398 | NULL, |
|
35024
eb3afb7643ce
Added /*< private >*/ for padding members, clean them up and add missing ones
Ankit Vani <a@nevitus.org>
parents:
34456
diff
changeset
|
1399 | NULL, |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1400 | NULL |
| 7016 | 1401 | }; |
| 1402 | ||
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1403 | static PurplePluginInfo * |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1404 | plugin_query(GError **error) |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1405 | { |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
1406 | const gchar * const authors[] = { |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
1407 | "Christian Hammond <chipx86@gnupdate.org>", |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
1408 | NULL |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
1409 | }; |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
1410 | |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1411 | return purple_plugin_info_new( |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1412 | "id", SSL_GNUTLS_PLUGIN_ID, |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1413 | "name", N_("GNUTLS"), |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1414 | "version", DISPLAY_VERSION, |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1415 | "category", N_("SSL"), |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1416 | "summary", N_("Provides SSL support through GNUTLS."), |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1417 | "description", N_("Provides SSL support through GNUTLS."), |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
1418 | "authors", authors, |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1419 | "website", PURPLE_WEBSITE, |
|
36505
60c161851325
Integrated purple ABI requirement into GPlugin's "abi-version" property
Ankit Vani <a@nevitus.org>
parents:
36501
diff
changeset
|
1420 | "abi-version", PURPLE_ABI_VERSION, |
|
36653
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36642
diff
changeset
|
1421 | "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL, |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1422 | NULL |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1423 | ); |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1424 | } |
|
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1425 | |
| 7016 | 1426 | static gboolean |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1427 | plugin_load(PurplePlugin *plugin, GError **error) |
| 7016 | 1428 | { |
| 15884 | 1429 | if(!purple_ssl_get_ops()) { |
| 1430 | purple_ssl_set_ops(&ssl_ops); | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
1431 | } |
| 7016 | 1432 | |
| 11033 | 1433 | /* Init GNUTLS now so others can use it even if sslconn never does */ |
| 1434 | ssl_gnutls_init_gnutls(); | |
| 1435 | ||
|
19356
65dacaaad968
- Move ssl-gnutls x509 registration until after GnuTLS itself is inited
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19353
diff
changeset
|
1436 | /* 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
|
1437 | 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
|
1438 | |
| 7016 | 1439 | return TRUE; |
| 1440 | } | |
| 1441 | ||
| 1442 | static gboolean | |
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1443 | plugin_unload(PurplePlugin *plugin, GError **error) |
| 7016 | 1444 | { |
| 15884 | 1445 | if(purple_ssl_get_ops() == &ssl_ops) { |
| 1446 | purple_ssl_set_ops(NULL); | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
1447 | } |
|
18447
27554a183269
- GnuTLS plugin registers an x509 certscheme now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18250
diff
changeset
|
1448 | |
|
27554a183269
- GnuTLS plugin registers an x509 certscheme now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18250
diff
changeset
|
1449 | purple_certificate_unregister_scheme( &x509_gnutls ); |
|
7050
12730863b0f9
[gaim-migrate @ 7613]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
1450 | |
| 7016 | 1451 | return TRUE; |
| 1452 | } | |
| 1453 | ||
|
36501
a7a71bf77f83
Refactored ssl plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1454 | PURPLE_PLUGIN_INIT(ssl_gnutls, plugin_query, plugin_load, plugin_unload); |