Sat, 08 Feb 2014 00:57:28 +0100
Fix some clang static analysis warnings
| 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" |
| 7016 | 25 | #include "plugin.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 | { | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
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 |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
47 | /* Priority strings. The default one is, well, the default (and is always |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
48 | * 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
|
49 | * char *). |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
50 | * |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
51 | * 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
|
52 | * 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
|
53 | * 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
|
54 | */ |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
55 | 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
|
56 | 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
|
57 | #endif |
| 7016 | 58 | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
59 | static void |
|
27407
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
60 | 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
|
61 | { |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
62 | /* 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
|
63 | 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
|
64 | } |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
65 | |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
66 | static void |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
67 | ssl_gnutls_init_gnutls(void) |
| 7016 | 68 | { |
|
27407
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
69 | 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
|
70 | 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
|
71 | |
|
17507
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
72 | /* Configure GnuTLS to use glib memory management */ |
|
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
73 | /* 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
|
74 | some bugs */ |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
75 | /* 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
|
76 | 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
|
77 | hypocrite) */ |
|
17507
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
78 | 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
|
79 | (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
|
80 | (gnutls_alloc_function) g_malloc, /* secure malloc */ |
|
17507
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
81 | NULL, /* mem_is_secure */ |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
82 | (gnutls_realloc_function) g_realloc, /* realloc */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
83 | (gnutls_free_function) g_free /* free */ |
|
17507
849f15622ee5
- GnuTLS uses glib memory mgmt
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17442
diff
changeset
|
84 | ); |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
85 | |
|
27407
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
86 | 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
|
87 | if (debug_level) { |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
88 | 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
|
89 | if (level < 0) { |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
90 | 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
|
91 | level); |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
92 | level = 0; |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
93 | } |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
94 | |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
95 | /* "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
|
96 | 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
|
97 | 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
|
98 | } |
|
dd036d781b36
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Paul Aurich <darkrain42@pidgin.im>
parents:
27337
diff
changeset
|
99 | |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
100 | /* 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
|
101 | * 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
|
102 | * libpurple. |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
103 | */ |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
104 | 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
|
105 | 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
|
106 | #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
|
107 | 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
|
108 | "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
|
109 | "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
|
110 | "this. :-("); |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
111 | #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
|
112 | 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
|
113 | 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
|
114 | guint i; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
115 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
116 | 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
|
117 | 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
|
118 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
119 | 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
|
120 | 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
|
121 | 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
|
122 | 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
|
123 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
124 | if (equals) { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
125 | *equals = '\0'; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
126 | 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
|
127 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
128 | /* Empty? */ |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
129 | 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
|
130 | 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
|
131 | "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
|
132 | } else { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
133 | /* 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
|
134 | 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
|
135 | /* Override the default priority */ |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
136 | g_free(default_priority_str); |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
137 | 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
|
138 | } else |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
139 | 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
|
140 | 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
|
141 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
142 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
143 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
144 | |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
145 | if (default_priority_str) { |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
146 | if (gnutls_priority_init(&default_priority, default_priority_str, NULL)) { |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
147 | purple_debug_warning("gnutls", "Unable to set default priority to %s\n", |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
148 | default_priority_str); |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
149 | /* Versions of GnuTLS as of 2.8.6 (2010-03-31) don't free/NULL |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
150 | * this on error. |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
151 | */ |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
152 | gnutls_free(default_priority); |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
153 | default_priority = NULL; |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
154 | } |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
155 | |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
156 | g_free(default_priority_str); |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
157 | } |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
158 | |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
159 | 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
|
160 | #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
|
161 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
162 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
163 | #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
|
164 | /* Make sure we set have a default priority! */ |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
165 | if (!default_priority) { |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
166 | if (gnutls_priority_init(&default_priority, "NORMAL:%SSL3_RECORD_VERSION", NULL)) { |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
167 | /* See comment above about memory leak */ |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
168 | gnutls_free(default_priority); |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
169 | gnutls_priority_init(&default_priority, "NORMAL", NULL); |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
170 | } |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
171 | } |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
172 | #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
|
173 | |
| 7016 | 174 | gnutls_global_init(); |
| 175 | ||
| 176 | gnutls_certificate_allocate_credentials(&xcred); | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
177 | |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
178 | /* TODO: I can likely remove this */ |
|
17430
95d550efcc3d
disapproval of revision '8976f9e287fef5bd2856c34ea931afa70a997895'
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17429
diff
changeset
|
179 | gnutls_certificate_set_x509_trust_file(xcred, "ca.pem", |
|
95d550efcc3d
disapproval of revision '8976f9e287fef5bd2856c34ea931afa70a997895'
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17429
diff
changeset
|
180 | GNUTLS_X509_FMT_PEM); |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
181 | } |
| 7016 | 182 | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
183 | static gboolean |
|
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
184 | ssl_gnutls_init(void) |
|
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
185 | { |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
186 | return TRUE; |
| 7016 | 187 | } |
| 188 | ||
| 189 | static void | |
| 190 | ssl_gnutls_uninit(void) | |
| 191 | { | |
| 192 | gnutls_global_deinit(); | |
| 193 | ||
| 194 | 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
|
195 | xcred = NULL; |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
196 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
197 | #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
|
198 | 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
|
199 | 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
|
200 | 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
|
201 | } |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
202 | |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
203 | 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
|
204 | 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
|
205 | #endif |
| 7016 | 206 | } |
| 207 | ||
|
18475
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
208 | static void |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
209 | ssl_gnutls_verified_cb(PurpleCertificateVerificationStatus st, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
210 | gpointer userdata) |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
211 | { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
212 | PurpleSslConnection *gsc = (PurpleSslConnection *) userdata; |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
213 | |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
214 | if (st == PURPLE_CERTIFICATE_VALID) { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
215 | /* Certificate valid? Good! Do the connection! */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
216 | 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
|
217 | } else { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
218 | /* Otherwise, signal an error */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
219 | if(gsc->error_cb != NULL) |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
220 | gsc->error_cb(gsc, PURPLE_SSL_CERTIFICATE_INVALID, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
221 | gsc->connect_cb_data); |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
222 | purple_ssl_close(gsc); |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
223 | } |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
224 | } |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
225 | |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
226 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
227 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
228 | static void ssl_gnutls_handshake_cb(gpointer data, gint source, |
| 15884 | 229 | PurpleInputCondition cond) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
230 | { |
| 15884 | 231 | PurpleSslConnection *gsc = data; |
| 232 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
233 | ssize_t ret; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
234 | |
|
20151
0b5ba1105191
applied changes from 5252885d793a4d288d92856d511d721bf5bb87ef
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
235 | /*purple_debug_info("gnutls", "Handshaking with %s\n", gsc->host);*/ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
236 | ret = gnutls_handshake(gnutls_data->session); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
237 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
238 | if(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
239 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
240 | |
| 15884 | 241 | purple_input_remove(gnutls_data->handshake_handler); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
242 | gnutls_data->handshake_handler = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
243 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
244 | if(ret != 0) { |
| 15884 | 245 | purple_debug_error("gnutls", "Handshake failed. Error %s\n", |
|
15846
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
246 | gnutls_strerror(ret)); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
247 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
248 | if(gsc->error_cb != NULL) |
| 15884 | 249 | gsc->error_cb(gsc, PURPLE_SSL_HANDSHAKE_FAILED, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
250 | gsc->connect_cb_data); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
251 | |
| 15884 | 252 | purple_ssl_close(gsc); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
253 | } else { |
|
18458
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
254 | /* Now we are cooking with gas! */ |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
255 | PurpleSslOps *ops = purple_ssl_get_ops(); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
256 | 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
|
257 | |
|
18458
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
258 | PurpleCertificateScheme *x509 = |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
259 | purple_certificate_find_scheme("x509"); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
260 | |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
261 | GList * l; |
|
19711
19b0780efe0e
Fix compiler warnings about having a variable declaration after some
Mark Doliner <markdoliner@pidgin.im>
parents:
19501
diff
changeset
|
262 | |
|
19b0780efe0e
Fix compiler warnings about having a variable declaration after some
Mark Doliner <markdoliner@pidgin.im>
parents:
19501
diff
changeset
|
263 | /* 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
|
264 | 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
|
265 | |
|
18458
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
266 | for (l=peers; l; l = l->next) { |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
267 | PurpleCertificate *crt = l->data; |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
268 | GByteArray *z = |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
269 | x509->get_fingerprint_sha1(crt); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
270 | gchar * fpr = |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
271 | purple_base16_encode_chunked(z->data, |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
272 | z->len); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
273 | |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
274 | purple_debug_info("gnutls/x509", |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
275 | "Key print: %s\n", |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
276 | fpr); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
277 | |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
278 | /* Kill the cert! */ |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
279 | 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
|
280 | |
|
18458
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
281 | g_free(fpr); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
282 | g_byte_array_free(z, TRUE); |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
283 | } |
|
e2f60e9d44aa
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18455
diff
changeset
|
284 | 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
|
285 | |
|
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
|
286 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
287 | 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
|
288 | guint cert_list_size = 0; |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
289 | gnutls_session_t session=gnutls_data->session; |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34302
diff
changeset
|
290 | guint i; |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
291 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
292 | cert_list = |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
293 | 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
|
294 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
295 | 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
|
296 | "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
|
297 | cert_list_size); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
298 | 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
|
299 | { |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
300 | 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
|
301 | 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
|
302 | 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
|
303 | gchar tbuf[256]; |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
304 | 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
|
305 | gchar * tasc = NULL; |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
306 | 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
|
307 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
308 | 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
|
309 | 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
|
310 | 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
|
311 | |
|
34456
d69aa7d3530c
Clang warnings: gnutls, gnome keyring and G_GNUC_*_IGNORE_DEPRECATIONS
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34304
diff
changeset
|
312 | 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
|
313 | 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
|
314 | |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
315 | fpr_asc = |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
316 | 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
|
317 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
318 | 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
|
319 | "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
|
320 | i, fpr_asc); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
321 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
322 | tsz=sizeof(tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
323 | 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
|
324 | 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
|
325 | 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
|
326 | "Serial: %s\n", |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
327 | tasc); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
328 | 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
|
329 | |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
330 | tsz=sizeof(tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
331 | 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
|
332 | 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
|
333 | "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
|
334 | tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
335 | tsz=sizeof(tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
336 | 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
|
337 | 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
|
338 | "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
|
339 | tbuf); |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
340 | |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
341 | 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
|
342 | fpr_asc = NULL; |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
343 | 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
|
344 | } |
|
17430
95d550efcc3d
disapproval of revision '8976f9e287fef5bd2856c34ea931afa70a997895'
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17429
diff
changeset
|
345 | } |
|
18475
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
346 | |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
347 | /* 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
|
348 | /* 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
|
349 | if (gsc->verifier) { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
350 | GList *peers; |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
351 | /* First, get the peer cert chain */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
352 | peers = purple_ssl_get_peer_certificates(gsc); |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
353 | |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
354 | /* Now kick off the verification process */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
355 | purple_certificate_verify(gsc->verifier, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
356 | gsc->host, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
357 | peers, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
358 | ssl_gnutls_verified_cb, |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
359 | gsc); |
|
18656
02c822b398d2
- purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18654
diff
changeset
|
360 | |
|
02c822b398d2
- purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18654
diff
changeset
|
361 | purple_certificate_destroy_list(peers); |
|
18475
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
362 | } else { |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
363 | /* Otherwise, just call the "connection complete" |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
364 | callback */ |
|
e3893e58c4c2
- ssl-gnutls plugin uses Verifiers now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18458
diff
changeset
|
365 | 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
|
366 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
367 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
368 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
369 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
370 | |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
371 | static gboolean |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
372 | 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
|
373 | { |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
374 | PurpleSslConnection *gsc = data; |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
375 | 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
|
376 | |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
377 | 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
|
378 | |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
379 | 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
|
380 | |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
381 | 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
|
382 | return FALSE; |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
383 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
384 | |
| 7016 | 385 | static void |
| 15884 | 386 | ssl_gnutls_connect(PurpleSslConnection *gsc) |
| 7016 | 387 | { |
| 15884 | 388 | PurpleSslGnutlsData *gnutls_data; |
| 7016 | 389 | |
| 15884 | 390 | gnutls_data = g_new0(PurpleSslGnutlsData, 1); |
| 7016 | 391 | gsc->private_data = gnutls_data; |
| 392 | ||
| 393 | 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
|
394 | #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
|
395 | { |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
396 | 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
|
397 | 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
|
398 | |
|
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
399 | /* 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
|
400 | 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
|
401 | 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
|
402 | |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
403 | if (prio_str) |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
404 | set = (GNUTLS_E_SUCCESS == |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
405 | 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
|
406 | NULL)); |
|
29939
4b6203acfa26
gnutls: Allow overriding (per-host) of GnuTLS priorities via env. Fixes #11616
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
407 | |
|
29940
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
408 | if (!set) |
|
7dd000cb5073
gnutls: Use gnutls_priority_init for the default priority.
Paul Aurich <darkrain42@pidgin.im>
parents:
29939
diff
changeset
|
409 | 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
|
410 | } |
|
25643
04831cc56f5a
Use _set_default_priority on gnutls versions lacking _priority_set_direct.
Ethan Blanton <elb@pidgin.im>
parents:
25642
diff
changeset
|
411 | #else |
|
04831cc56f5a
Use _set_default_priority on gnutls versions lacking _priority_set_direct.
Ethan Blanton <elb@pidgin.im>
parents:
25642
diff
changeset
|
412 | 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
|
413 | #endif |
| 7016 | 414 | |
|
35382
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35024
diff
changeset
|
415 | if (gsc->host) { |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35024
diff
changeset
|
416 | 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
|
417 | gsc->host, strlen(gsc->host)); |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35024
diff
changeset
|
418 | } |
| 7016 | 419 | |
| 420 | gnutls_credentials_set(gnutls_data->session, GNUTLS_CRD_CERTIFICATE, | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
421 | xcred); |
| 7016 | 422 | |
|
14223
c6ba4f3482de
[gaim-migrate @ 16809]
Mark Doliner <markdoliner@pidgin.im>
parents:
13985
diff
changeset
|
423 | gnutls_transport_set_ptr(gnutls_data->session, GINT_TO_POINTER(gsc->fd)); |
| 7016 | 424 | |
| 15884 | 425 | gnutls_data->handshake_handler = purple_input_add(gsc->fd, |
| 426 | PURPLE_INPUT_READ, ssl_gnutls_handshake_cb, gsc); | |
| 7016 | 427 | |
|
17345
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
428 | /* 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
|
429 | (almost) immediately calling it? |
|
17345
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
430 | |
|
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
431 | 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
|
432 | 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
|
433 | 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
|
434 | the callback. |
|
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
435 | |
|
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
436 | 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
|
437 | 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
|
438 | accomplish this. |
|
cbe9758e542e
- Document some weird-looking logic in the GnuTLS plugin.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
16744
diff
changeset
|
439 | */ |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29940
diff
changeset
|
440 | 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
|
441 | gsc); |
| 7016 | 442 | } |
| 443 | ||
| 444 | static void | |
| 15884 | 445 | ssl_gnutls_close(PurpleSslConnection *gsc) |
| 7016 | 446 | { |
| 15884 | 447 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
| 7016 | 448 | |
| 7467 | 449 | if(!gnutls_data) |
| 450 | return; | |
| 451 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
452 | if(gnutls_data->handshake_handler) |
| 15884 | 453 | 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
|
454 | 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
|
455 | purple_timeout_remove(gnutls_data->handshake_timer); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
456 | |
| 7016 | 457 | gnutls_bye(gnutls_data->session, GNUTLS_SHUT_RDWR); |
| 458 | ||
| 459 | gnutls_deinit(gnutls_data->session); | |
| 460 | ||
| 461 | g_free(gnutls_data); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
462 | gsc->private_data = NULL; |
| 7016 | 463 | } |
| 464 | ||
| 465 | static size_t | |
| 15884 | 466 | ssl_gnutls_read(PurpleSslConnection *gsc, void *data, size_t len) |
| 7016 | 467 | { |
| 15884 | 468 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
469 | ssize_t s; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
470 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
471 | s = gnutls_record_recv(gnutls_data->session, data, len); |
| 7016 | 472 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
473 | if(s == GNUTLS_E_AGAIN || s == GNUTLS_E_INTERRUPTED) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
474 | s = -1; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
475 | errno = EAGAIN; |
|
34302
3949b825f4bf
Compile with older GnuTLS versions, without GNUTLS_E_PREMATURE_TERMINATION; GTK: don't let inline images overflow the window
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34295
diff
changeset
|
476 | #ifdef GNUTLS_E_PREMATURE_TERMINATION |
|
34295
f50c94ec0021
HTTP: content compression support (gzip, deflate); added hard max length limit; fixed crashes after free; GnuTLS: treat GNUTLS_E_PREMATURE_TERMINATION indulgently
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34290
diff
changeset
|
477 | } else if (s == GNUTLS_E_PREMATURE_TERMINATION) { |
|
f50c94ec0021
HTTP: content compression support (gzip, deflate); added hard max length limit; fixed crashes after free; GnuTLS: treat GNUTLS_E_PREMATURE_TERMINATION indulgently
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34290
diff
changeset
|
478 | purple_debug_warning("gnutls", "premature termination\n"); |
|
f50c94ec0021
HTTP: content compression support (gzip, deflate); added hard max length limit; fixed crashes after free; GnuTLS: treat GNUTLS_E_PREMATURE_TERMINATION indulgently
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34290
diff
changeset
|
479 | s = 0; |
|
34302
3949b825f4bf
Compile with older GnuTLS versions, without GNUTLS_E_PREMATURE_TERMINATION; GTK: don't let inline images overflow the window
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34295
diff
changeset
|
480 | #endif |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
481 | } else if(s < 0) { |
| 15884 | 482 | 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
|
483 | gnutls_strerror(s)); |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
484 | s = -1; |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
485 | /* |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
486 | * 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
|
487 | * 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
|
488 | * 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
|
489 | * that returns the error message. |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
490 | */ |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
491 | errno = EIO; |
| 7834 | 492 | } |
| 7016 | 493 | |
| 494 | return s; | |
| 495 | } | |
| 496 | ||
| 497 | static size_t | |
| 15884 | 498 | ssl_gnutls_write(PurpleSslConnection *gsc, const void *data, size_t len) |
| 7016 | 499 | { |
| 15884 | 500 | PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
501 | ssize_t s = 0; |
| 7016 | 502 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
503 | /* XXX: when will gnutls_data be NULL? */ |
| 7467 | 504 | if(gnutls_data) |
| 505 | s = gnutls_record_send(gnutls_data->session, data, len); | |
| 7016 | 506 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
507 | if(s == GNUTLS_E_AGAIN || s == GNUTLS_E_INTERRUPTED) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
508 | s = -1; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
509 | errno = EAGAIN; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
510 | } else if(s < 0) { |
| 15884 | 511 | 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
|
512 | gnutls_strerror(s)); |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
513 | s = -1; |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
514 | /* |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
515 | * 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
|
516 | * 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
|
517 | * 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
|
518 | * that returns the error message. |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
519 | */ |
|
7a956b382f6c
There were a few problems here
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
520 | errno = EIO; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
521 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11513
diff
changeset
|
522 | |
| 7016 | 523 | return s; |
| 524 | } | |
| 525 | ||
|
19494
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
526 | /* Forward declarations are fun! */ |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
527 | static PurpleCertificate * |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
528 | 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
|
529 | /* 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
|
530 | 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
|
531 | 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
|
532 | 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
|
533 | 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
|
534 | x509_destroy_certificate(PurpleCertificate * crt); |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
535 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
536 | static GList * |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
537 | ssl_gnutls_get_peer_certificates(PurpleSslConnection * gsc) |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
538 | { |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
539 | 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
|
540 | PurpleCertificate *prvcrt = NULL; |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
541 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
542 | /* List of Certificate instances to return */ |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
543 | GList * peer_certs = NULL; |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
544 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
545 | /* List of raw certificates as given by GnuTLS */ |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
546 | const gnutls_datum_t *cert_list; |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
547 | unsigned int cert_list_size = 0; |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
548 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
549 | 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
|
550 | |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
551 | /* This should never, ever happen. */ |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
552 | 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
|
553 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
554 | /* Get the certificate list from GnuTLS */ |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
555 | /* 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
|
556 | 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
|
557 | &cert_list_size); |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
558 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
559 | /* 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
|
560 | for (i = 0; i < cert_list_size; i++) { |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
561 | 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
|
562 | GNUTLS_X509_FMT_DER); |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
563 | /* 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
|
564 | 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
|
565 | 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
|
566 | /* 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
|
567 | * 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
|
568 | 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
|
569 | 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
|
570 | 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
|
571 | } 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
|
572 | 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
|
573 | 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
|
574 | "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
|
575 | 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
|
576 | } |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
577 | } |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
578 | |
|
19494
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
579 | /* cert_list doesn't need free()-ing */ |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
580 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
581 | return peer_certs; |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
582 | } |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
583 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
584 | /************************************************************************/ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
585 | /* X.509 functionality */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
586 | /************************************************************************/ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
587 | const gchar * SCHEME_NAME = "x509"; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
588 | |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
589 | static PurpleCertificateScheme x509_gnutls; |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
590 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
591 | /** 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
|
592 | typedef struct { |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
593 | gint refcount; |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
594 | 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
|
595 | } x509_crtdata_t; |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
596 | |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
597 | /** 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
|
598 | static x509_crtdata_t * |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
599 | 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
|
600 | { |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
601 | (cd->refcount)++; |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
602 | return cd; |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
603 | } |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
604 | |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
605 | static void |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
606 | 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
|
607 | { |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
608 | (cd->refcount)--; |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
609 | |
|
19714
b424012723a8
refcount of 0 is normal
Mark Doliner <markdoliner@pidgin.im>
parents:
19713
diff
changeset
|
610 | 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
|
611 | 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
|
612 | "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
|
613 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
614 | /* 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
|
615 | 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
|
616 | /* Kill the internal data */ |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
617 | 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
|
618 | /* And kill the struct */ |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
619 | g_free( cd ); |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
620 | } |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
621 | } |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
622 | |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
623 | /** 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
|
624 | #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
|
625 | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
626 | /** 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
|
627 | * |
|
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
|
628 | * @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
|
629 | * @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
|
630 | * 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
|
631 | * "over the wire" certs for SSL) |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
632 | * |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
633 | * @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
|
634 | */ |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
635 | static PurpleCertificate * |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
636 | 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
|
637 | { |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
638 | /* 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
|
639 | x509_crtdata_t *certdat; |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
640 | /* New certificate to return */ |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
641 | PurpleCertificate * crt; |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
642 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
643 | /* 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
|
644 | 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
|
645 | 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
|
646 | 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
|
647 | |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
648 | /* 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
|
649 | /* 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
|
650 | 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
|
651 | |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
652 | /* 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
|
653 | crt = g_new0(PurpleCertificate, 1); |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
654 | 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
|
655 | crt->data = x509_crtdata_addref(certdat); |
|
17510
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
656 | |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
657 | return crt; |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
658 | } |
|
b9314561d25a
- Wrote GnuTLS get_peer_certificates function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
659 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
660 | /** 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
|
661 | * @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
|
662 | * |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
663 | * @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
|
664 | */ |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
665 | static PurpleCertificate * |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
666 | 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
|
667 | { |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
668 | PurpleCertificate *crt; /* Certificate being constructed */ |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
669 | 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
|
670 | gsize buf_sz; /* Size of the above */ |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
671 | 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
|
672 | |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
673 | purple_debug_info("gnutls", |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
674 | "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
|
675 | filename); |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
676 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
677 | /* 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
|
678 | into memory */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
679 | /* TODO: Should I worry about very large files here? */ |
|
19494
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
680 | g_return_val_if_fail( |
|
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
681 | g_file_get_contents(filename, |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
682 | &buf, |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
683 | &buf_sz, |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
684 | NULL /* No error checking for now */ |
|
19494
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
685 | ), |
|
c9ee38003eb6
- TODO-whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19359
diff
changeset
|
686 | NULL); |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
687 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
688 | /* Load the datum struct */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
689 | dt.data = (unsigned char *) buf; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
690 | dt.size = buf_sz; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
691 | |
|
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
|
692 | /* 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
|
693 | 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
|
694 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
695 | /* Cleanup */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
696 | g_free(buf); |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
697 | |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
698 | return crt; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
699 | } |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
700 | |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
701 | /** 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
|
702 | * @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
|
703 | * |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
704 | * @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
|
705 | */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
706 | static GSList * |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
707 | 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
|
708 | { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
709 | PurpleCertificate *crt; /* Certificate being constructed */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
710 | 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
|
711 | gchar *begin, *end; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
712 | GSList *crts = NULL; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
713 | gsize buf_sz; /* Size of the above */ |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
714 | 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
|
715 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
716 | purple_debug_info("gnutls", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
717 | "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
|
718 | filename); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
719 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
720 | /* 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
|
721 | into memory */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
722 | /* 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
|
723 | g_return_val_if_fail( |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
724 | g_file_get_contents(filename, |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
725 | &buf, |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
726 | &buf_sz, |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
727 | 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
|
728 | ), |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
729 | NULL); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
730 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
731 | begin = buf; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
732 | 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
|
733 | end += sizeof("-----END CERTIFICATE-----")-1; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
734 | /* Load the datum struct */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
735 | dt.data = (unsigned char *) begin; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
736 | dt.size = (end-begin); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
737 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
738 | /* 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
|
739 | 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
|
740 | 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
|
741 | begin = end; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
742 | } |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
743 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
744 | /* Cleanup */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
745 | g_free(buf); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
746 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
747 | return crts; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
748 | } |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28655
diff
changeset
|
749 | |
|
18496
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
750 | /** |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
751 | * 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
|
752 | * @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
|
753 | * @param crt Certificate to export |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
754 | * |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
755 | * @return TRUE if success, otherwise FALSE |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
756 | */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
757 | static gboolean |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
758 | 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
|
759 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
760 | 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
|
761 | int ret; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
762 | gchar * out_buf; /* Data to output */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
763 | size_t out_size; /* Output size */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
764 | gboolean success = FALSE; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
765 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
766 | /* Paranoia paranoia paranoia! */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
767 | 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
|
768 | 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
|
769 | 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
|
770 | 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
|
771 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
772 | 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
|
773 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
774 | /* Obtain the output size required */ |
|
18593
9d2bd532bf74
- Fix intermittent crash due to uninitialized variable
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18592
diff
changeset
|
775 | out_size = 0; |
|
18496
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
776 | 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
|
777 | NULL, /* Provide no buffer yet */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
778 | &out_size /* Put size here */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
779 | ); |
|
18591
9d7c99e312b9
- Fix an incorrect assertion in GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18496
diff
changeset
|
780 | 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
|
781 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
782 | /* 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
|
783 | 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
|
784 | 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
|
785 | 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
|
786 | &out_size /* Put size here */ |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
787 | ); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
788 | if (ret != 0) { |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
789 | purple_debug_error("gnutls/x509", |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
790 | "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
|
791 | ret); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
792 | g_free(out_buf); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
793 | return FALSE; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
794 | } |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
795 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
796 | /* 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
|
797 | 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
|
798 | out_buf, out_size); |
|
18496
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
799 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
800 | g_free(out_buf); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
801 | return success; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
802 | } |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18482
diff
changeset
|
803 | |
|
18654
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
804 | static PurpleCertificate * |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
805 | x509_copy_certificate(PurpleCertificate *crt) |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
806 | { |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
807 | x509_crtdata_t *crtdat; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
808 | PurpleCertificate *newcrt; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
809 | |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
810 | g_return_val_if_fail(crt, NULL); |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
811 | 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
|
812 | |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
813 | crtdat = (x509_crtdata_t *) crt->data; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
814 | |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
815 | newcrt = g_new0(PurpleCertificate, 1); |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
816 | newcrt->scheme = &x509_gnutls; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
817 | newcrt->data = x509_crtdata_addref(crtdat); |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
818 | |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
819 | return newcrt; |
|
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
820 | } |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
821 | /** Frees a Certificate |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
822 | * |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
823 | * 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
|
824 | * given. |
|
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
825 | * @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
|
826 | * 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
|
827 | * |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
828 | */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
829 | static void |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
830 | x509_destroy_certificate(PurpleCertificate * crt) |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
831 | { |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
832 | if (NULL == crt) return; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
833 | |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
834 | /* 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
|
835 | if ( crt->scheme != &x509_gnutls ) { |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
836 | purple_debug_error("gnutls", |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
837 | "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
|
838 | crt->scheme->name, |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
839 | SCHEME_NAME); |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
840 | return; |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
841 | } |
|
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 | 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
|
844 | 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
|
845 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
846 | /* 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
|
847 | underlying data */ |
|
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
848 | 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
|
849 | |
|
17509
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
850 | /* Kill the structure itself */ |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
851 | g_free(crt); |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
852 | } |
|
fa009823dbfd
- Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17507
diff
changeset
|
853 | |
|
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
|
854 | /** 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
|
855 | * |
|
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
|
856 | * @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
|
857 | * @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
|
858 | * |
|
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
|
859 | * @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
|
860 | * @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
|
861 | */ |
|
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
|
862 | 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
|
863 | 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
|
864 | 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
|
865 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
866 | gnutls_x509_crt_t crt_dat; |
|
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
867 | 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
|
868 | 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
|
869 | 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
|
870 | 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
|
871 | 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
|
872 | |
|
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
|
873 | 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
|
874 | 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
|
875 | |
|
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
|
876 | /* 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
|
877 | 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
|
878 | 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
|
879 | |
|
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
|
880 | /* 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
|
881 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
882 | 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
|
883 | 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
|
884 | |
|
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
|
885 | /* First, let's check that crt.issuer is actually issuer */ |
|
d7663374e33d
- Add x509_certificate_signed_by, which checks a signature on a certificate made by an issuer
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18248
diff
changeset
|
886 | 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
|
887 | 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
|
888 | |
|
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
|
889 | 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
|
890 | 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
|
891 | "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
|
892 | ret); |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
893 | } else { |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
894 | gchar *crt_id, *issuer_id, *crt_issuer_id; |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
895 | crt_id = purple_certificate_get_unique_id(crt); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
896 | issuer_id = purple_certificate_get_unique_id(issuer); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
897 | crt_issuer_id = |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
898 | purple_certificate_get_issuer_unique_id(crt); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
899 | 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
|
900 | "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
|
901 | "%s, which does not match %s.\n", |
|
20177
92af9f603b75
applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@pidgin.im>
parents:
20176
diff
changeset
|
902 | crt_id ? crt_id : "(null)", |
|
92af9f603b75
applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@pidgin.im>
parents:
20176
diff
changeset
|
903 | crt_issuer_id ? crt_issuer_id : "(null)", |
|
92af9f603b75
applied changes from f143c30a12f30c53e017f1bfc22ccddee96036fc
Richard Laager <rlaager@pidgin.im>
parents:
20176
diff
changeset
|
904 | 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
|
905 | g_free(crt_id); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
906 | g_free(issuer_id); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
907 | 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
|
908 | } |
|
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
|
909 | |
|
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
|
910 | /* 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
|
911 | 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
|
912 | } |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
913 | |
|
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
|
914 | /* 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
|
915 | /* 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
|
916 | 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
|
917 | 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
|
918 | /* 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
|
919 | (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
|
920 | 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
|
921 | 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
|
922 | 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
|
923 | &verify); |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
924 | |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
925 | 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
|
926 | 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
|
927 | "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
|
928 | 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
|
929 | } |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
930 | |
|
28652
46da88b82471
Check the GnuTLS version before using a recent-ish flag. Fixes #10412.
Paul Aurich <darkrain42@pidgin.im>
parents:
27917
diff
changeset
|
931 | #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
|
932 | 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
|
933 | /* |
|
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
|
934 | * 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
|
935 | * 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
|
936 | * 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
|
937 | * 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
|
938 | */ |
|
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
|
939 | crt_id = purple_certificate_get_unique_id(crt); |
|
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
|
940 | issuer_id = purple_certificate_get_issuer_unique_id(crt); |
|
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
|
941 | 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
|
942 | "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
|
943 | 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
|
944 | } |
|
28652
46da88b82471
Check the GnuTLS version before using a recent-ish flag. Fixes #10412.
Paul Aurich <darkrain42@pidgin.im>
parents:
27917
diff
changeset
|
945 | #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
|
946 | |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
947 | 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
|
948 | /* 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
|
949 | 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
|
950 | if (!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
|
951 | crt_id = purple_certificate_get_unique_id(crt); |
|
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
|
952 | if (!issuer_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
|
953 | issuer_id = purple_certificate_get_issuer_unique_id(crt); |
|
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
|
954 | 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
|
955 | "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
|
956 | issuer_id, crt_id); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
957 | g_free(crt_id); |
|
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
958 | 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
|
959 | |
|
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
|
960 | 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
|
961 | } /* 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
|
962 | |
|
19353
bf6a0230d8e7
- Fix x509_signed_by. Apparently I can't read documentation.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19019
diff
changeset
|
963 | /* 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
|
964 | 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
|
965 | } |
|
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
|
966 | |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
967 | static GByteArray * |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
968 | x509_sha1sum(PurpleCertificate *crt) |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
969 | { |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
970 | size_t hashlen = 20; /* SHA1 hashes are 20 bytes */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
971 | size_t tmpsz = hashlen; /* Throw-away variable for GnuTLS to stomp on*/ |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
972 | gnutls_x509_crt_t crt_dat; |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
973 | GByteArray *hash; /**< Final hash container */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
974 | guchar hashbuf[hashlen]; /**< Temporary buffer to contain hash */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
975 | |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
976 | g_return_val_if_fail(crt, NULL); |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
977 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
978 | crt_dat = X509_GET_GNUTLS_DATA(crt); |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
979 | |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
980 | /* Extract the fingerprint */ |
|
19495
af7b321844ab
- More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19494
diff
changeset
|
981 | g_return_val_if_fail( |
|
34456
d69aa7d3530c
Clang warnings: gnutls, gnome keyring and G_GNUC_*_IGNORE_DEPRECATIONS
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34304
diff
changeset
|
982 | 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
|
983 | hashbuf, &tmpsz), |
|
af7b321844ab
- More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19494
diff
changeset
|
984 | NULL); |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
985 | |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
986 | /* This shouldn't happen */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
987 | 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
|
988 | |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
989 | /* Okay, now create and fill hash array */ |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
990 | hash = g_byte_array_new(); |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
991 | g_byte_array_append(hash, hashbuf, hashlen); |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
992 | |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
993 | return hash; |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
994 | } |
|
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
995 | |
|
18482
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
996 | static gchar * |
|
19019
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
997 | 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
|
998 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
999 | 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
|
1000 | gchar *dn = NULL; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1001 | 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
|
1002 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1003 | 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
|
1004 | 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
|
1005 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1006 | 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
|
1007 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1008 | /* 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
|
1009 | /* 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
|
1010 | space it needs */ |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1011 | dn_size = 0; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1012 | 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
|
1013 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1014 | /* Now allocate and get the Distinguished Name */ |
|
20175
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1015 | /* 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
|
1016 | 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
|
1017 | an extra byte */ |
|
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1018 | dn = g_new0(gchar, ++dn_size); |
|
19496
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1019 | 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
|
1020 | purple_debug_error("gnutls/x509", |
|
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1021 | "Failed to get Distinguished Name\n"); |
|
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1022 | g_free(dn); |
|
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1023 | return NULL; |
|
648d59dc3bfa
- Errorchecking in x509_cert_dn
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
1024 | } |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
1025 | |
|
19019
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1026 | return dn; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1027 | } |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1028 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1029 | static gchar * |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1030 | 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
|
1031 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
1032 | 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
|
1033 | gchar *dn = NULL; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1034 | 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
|
1035 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1036 | 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
|
1037 | 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
|
1038 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1039 | 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
|
1040 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1041 | /* 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
|
1042 | /* 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
|
1043 | space it needs */ |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1044 | dn_size = 0; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1045 | 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
|
1046 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1047 | /* Now allocate and get the Distinguished Name */ |
|
20175
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1048 | /* 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
|
1049 | 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
|
1050 | an extra byte */ |
|
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1051 | dn = g_new0(gchar, ++dn_size); |
|
19497
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1052 | 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
|
1053 | purple_debug_error("gnutls/x509", |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1054 | "Failed to get issuer's Distinguished " |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1055 | "Name\n"); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1056 | g_free(dn); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1057 | return NULL; |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1058 | } |
|
19712
658159391efc
Get rid of some stray whitespace and consistently use tab indentation
Mark Doliner <markdoliner@pidgin.im>
parents:
19711
diff
changeset
|
1059 | |
|
19019
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1060 | return dn; |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1061 | } |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1062 | |
|
d2415aad4cfb
- Add unique_id and issuer_unique_id constructions (defined as Distinguished
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
1063 | static gchar * |
|
18482
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1064 | 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
|
1065 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
1066 | 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
|
1067 | gchar *cn = NULL; |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1068 | size_t cn_size; |
|
19497
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1069 | int ret; |
|
18482
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1070 | |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1071 | 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
|
1072 | 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
|
1073 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
1074 | 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
|
1075 | |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1076 | /* 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
|
1077 | /* 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
|
1078 | space it needs */ |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1079 | cn_size = 0; |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1080 | 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
|
1081 | 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
|
1082 | 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
|
1083 | 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
|
1084 | cn, &cn_size); |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1085 | |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1086 | /* Now allocate and get the Common Name */ |
|
20175
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1087 | /* 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
|
1088 | 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
|
1089 | an extra byte */ |
|
0785c8f62a58
applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971
Richard Laager <rlaager@pidgin.im>
parents:
20174
diff
changeset
|
1090 | cn = g_new0(gchar, ++cn_size); |
|
19497
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1091 | ret = gnutls_x509_crt_get_dn_by_oid(cert_dat, |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1092 | GNUTLS_OID_X520_COMMON_NAME, |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1093 | 0, /* First CN found, please */ |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1094 | 0, /* Not in raw mode */ |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1095 | cn, &cn_size); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1096 | if (ret != 0) { |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1097 | purple_debug_error("gnutls/x509", |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1098 | "Failed to get Common Name\n"); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1099 | g_free(cn); |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1100 | return NULL; |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1101 | } |
|
9766bb35cc02
- Yet More TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1102 | |
|
18482
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1103 | return cn; |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1104 | } |
|
be73de06d821
- Add subject_name (AKA Common Name) functions to GnuTLS x509 scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18480
diff
changeset
|
1105 | |
|
18643
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1106 | static gboolean |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1107 | 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
|
1108 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
1109 | 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
|
1110 | |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1111 | 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
|
1112 | 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
|
1113 | 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
|
1114 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
1115 | 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
|
1116 | |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1117 | 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
|
1118 | return TRUE; |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1119 | } else { |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1120 | return FALSE; |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1121 | } |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1122 | } |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1123 | |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1124 | 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
|
1125 | 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
|
1126 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
1127 | 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
|
1128 | /* 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
|
1129 | const time_t errval = (time_t) (-1); |
|
20224
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1130 | gboolean success = TRUE; |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1131 | |
|
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1132 | 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
|
1133 | 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
|
1134 | |
|
18652
0998769e4fea
- GnuTLS plugin now uses reference counting to manage its underlying
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18648
diff
changeset
|
1135 | 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
|
1136 | |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1137 | if (activation) { |
|
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1138 | *activation = gnutls_x509_crt_get_activation_time(crt_dat); |
|
20224
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1139 | if (*activation == errval) |
|
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1140 | success = FALSE; |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1141 | } |
|
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1142 | if (expiration) { |
|
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1143 | *expiration = gnutls_x509_crt_get_expiration_time(crt_dat); |
|
20224
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1144 | if (*expiration == errval) |
|
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1145 | success = FALSE; |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1146 | } |
|
18648
a677b7c8fd97
- Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18643
diff
changeset
|
1147 | |
|
20224
d4b827c606db
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20177
diff
changeset
|
1148 | return success; |
|
18648
a677b7c8fd97
- Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18643
diff
changeset
|
1149 | } |
|
a677b7c8fd97
- Add activation/expiration time retrievers to GnuTLS plugin
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18643
diff
changeset
|
1150 | |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1151 | static GByteArray * |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1152 | 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
|
1153 | { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32885
diff
changeset
|
1154 | 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
|
1155 | GByteArray *data; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1156 | 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
|
1157 | int ret; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1158 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1159 | 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
|
1160 | 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
|
1161 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1162 | /* 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
|
1163 | len = 0; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1164 | 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
|
1165 | 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
|
1166 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1167 | /* 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
|
1168 | 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
|
1169 | 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
|
1170 | 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
|
1171 | 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
|
1172 | 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
|
1173 | "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
|
1174 | ret); |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1175 | 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
|
1176 | return NULL; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1177 | } |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1178 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1179 | return data; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1180 | } |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31155
diff
changeset
|
1181 | |
|
32885
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1182 | static gchar * |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1183 | x509_display_string(PurpleCertificate *crt) |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1184 | { |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1185 | gchar *sha_asc; |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1186 | GByteArray *sha_bin; |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1187 | gchar *cn; |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1188 | gint64 activation, expiration; |
|
32885
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1189 | gchar *activ_str, *expir_str; |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1190 | gchar *text; |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1191 | #if GLIB_CHECK_VERSION(2,26,0) |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1192 | GDateTime *act_dt, *exp_dt; |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1193 | #endif |
|
32885
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1194 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1195 | /* Pull out the SHA1 checksum */ |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1196 | sha_bin = x509_sha1sum(crt); |
|
35382
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35024
diff
changeset
|
1197 | g_return_val_if_fail(sha_bin != NULL, NULL); |
|
32885
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1198 | sha_asc = purple_base16_encode_chunked(sha_bin->data, sha_bin->len); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1199 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1200 | /* Get the cert Common Name */ |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1201 | /* TODO: Will break on CA certs */ |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1202 | cn = x509_common_name(crt); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1203 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1204 | /* Get the certificate times */ |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1205 | /* TODO: Check the times against localtime */ |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1206 | /* TODO: errorcheck? */ |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1207 | if (!x509_times(crt, &activation, &expiration)) { |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1208 | purple_debug_error("certificate", |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1209 | "Failed to get certificate times!\n"); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1210 | activation = expiration = 0; |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1211 | } |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1212 | |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1213 | #if GLIB_CHECK_VERSION(2,26,0) |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1214 | act_dt = g_date_time_new_from_unix_local(activation); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1215 | activ_str = g_date_time_format(act_dt, "%c"); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1216 | g_date_time_unref(act_dt); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1217 | |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1218 | exp_dt = g_date_time_new_from_unix_local(expiration); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1219 | expir_str = g_date_time_format(exp_dt, "%c"); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1220 | g_date_time_unref(exp_dt); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1221 | #else |
|
32885
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1222 | activ_str = g_strdup(ctime(&activation)); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1223 | expir_str = g_strdup(ctime(&expiration)); |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33892
diff
changeset
|
1224 | #endif |
|
32885
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1225 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1226 | /* Make messages */ |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1227 | text = g_strdup_printf(_("Common name: %s\n\n" |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1228 | "Fingerprint (SHA1): %s\n\n" |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1229 | "Activation date: %s\n" |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1230 | "Expiration date: %s\n"), |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1231 | cn ? cn : "(null)", |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1232 | sha_asc ? sha_asc : "(null)", |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1233 | activ_str ? activ_str : "(null)", |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1234 | expir_str ? expir_str : "(null)"); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1235 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1236 | /* Cleanup */ |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1237 | g_free(cn); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1238 | g_free(sha_asc); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1239 | g_free(activ_str); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1240 | g_free(expir_str); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1241 | g_byte_array_free(sha_bin, TRUE); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1242 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1243 | return text; |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1244 | } |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1245 | |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1246 | /* X.509 certificate operations provided by this plugin */ |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1247 | static PurpleCertificateScheme x509_gnutls = { |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1248 | "x509", /* Scheme name */ |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1249 | N_("X.509 Certificates"), /* User-visible scheme name */ |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1250 | 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
|
1251 | x509_export_certificate, /* Certificate export function */ |
|
18654
45790c3e780d
- Add GnuTLS X.509 cert copy operator
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
1252 | x509_copy_certificate, /* Copy */ |
|
18454
9a56a88152b9
- Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18450
diff
changeset
|
1253 | x509_destroy_certificate, /* Destroy cert */ |
|
19016
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19007
diff
changeset
|
1254 | x509_certificate_signed_by, /* Signature checker */ |
|
18455
4fe7da78f38d
- Add GnuTLS SHA1 key fingerprinter
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18454
diff
changeset
|
1255 | 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
|
1256 | 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
|
1257 | 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
|
1258 | x509_common_name, /* Subject name */ |
|
18643
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18642
diff
changeset
|
1259 | x509_check_name, /* Check subject name */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19714
diff
changeset
|
1260 | 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
|
1261 | 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
|
1262 | x509_get_der_data, /* Binary DER data */ |
|
32885
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
1263 | x509_display_string, /* Display representation */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19714
diff
changeset
|
1264 | |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19714
diff
changeset
|
1265 | NULL |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19714
diff
changeset
|
1266 | |
|
18248
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1267 | }; |
|
8f462eaffecd
- Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18247
diff
changeset
|
1268 | |
| 15884 | 1269 | static PurpleSslOps ssl_ops = |
| 7016 | 1270 | { |
| 1271 | ssl_gnutls_init, | |
| 1272 | ssl_gnutls_uninit, | |
|
14223
c6ba4f3482de
[gaim-migrate @ 16809]
Mark Doliner <markdoliner@pidgin.im>
parents:
13985
diff
changeset
|
1273 | ssl_gnutls_connect, |
| 7016 | 1274 | ssl_gnutls_close, |
| 1275 | ssl_gnutls_read, | |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1276 | 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
|
1277 | ssl_gnutls_get_peer_certificates, |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1278 | |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1279 | /* padding */ |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1280 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1281 | NULL, |
|
35024
eb3afb7643ce
Added /*< private >*/ for padding members, clean them up and add missing ones
Ankit Vani <a@nevitus.org>
parents:
34456
diff
changeset
|
1282 | NULL, |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1283 | NULL |
| 7016 | 1284 | }; |
| 1285 | ||
| 1286 | static gboolean | |
| 15884 | 1287 | plugin_load(PurplePlugin *plugin) |
| 7016 | 1288 | { |
| 15884 | 1289 | if(!purple_ssl_get_ops()) { |
| 1290 | purple_ssl_set_ops(&ssl_ops); | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
1291 | } |
| 7016 | 1292 | |
| 11033 | 1293 | /* Init GNUTLS now so others can use it even if sslconn never does */ |
| 1294 | ssl_gnutls_init_gnutls(); | |
| 1295 | ||
|
19356
65dacaaad968
- Move ssl-gnutls x509 registration until after GnuTLS itself is inited
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19353
diff
changeset
|
1296 | /* 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
|
1297 | 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
|
1298 | |
| 7016 | 1299 | return TRUE; |
| 1300 | } | |
| 1301 | ||
| 1302 | static gboolean | |
| 15884 | 1303 | plugin_unload(PurplePlugin *plugin) |
| 7016 | 1304 | { |
| 15884 | 1305 | if(purple_ssl_get_ops() == &ssl_ops) { |
| 1306 | purple_ssl_set_ops(NULL); | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7834
diff
changeset
|
1307 | } |
|
18447
27554a183269
- GnuTLS plugin registers an x509 certscheme now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18250
diff
changeset
|
1308 | |
|
27554a183269
- GnuTLS plugin registers an x509 certscheme now
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18250
diff
changeset
|
1309 | purple_certificate_unregister_scheme( &x509_gnutls ); |
|
7050
12730863b0f9
[gaim-migrate @ 7613]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
1310 | |
| 7016 | 1311 | return TRUE; |
| 1312 | } | |
| 1313 | ||
| 15884 | 1314 | static PurplePluginInfo info = |
| 7016 | 1315 | { |
| 15884 | 1316 | PURPLE_PLUGIN_MAGIC, |
| 1317 | PURPLE_MAJOR_VERSION, | |
| 1318 | PURPLE_MINOR_VERSION, | |
| 1319 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
| 7016 | 1320 | NULL, /**< ui_requirement */ |
| 15884 | 1321 | PURPLE_PLUGIN_FLAG_INVISIBLE, /**< flags */ |
| 7016 | 1322 | NULL, /**< dependencies */ |
| 15884 | 1323 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 7016 | 1324 | |
| 1325 | SSL_GNUTLS_PLUGIN_ID, /**< id */ | |
| 1326 | N_("GNUTLS"), /**< name */ | |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20224
diff
changeset
|
1327 | DISPLAY_VERSION, /**< version */ |
| 7016 | 1328 | /** summary */ |
| 1329 | N_("Provides SSL support through GNUTLS."), | |
| 1330 | /** description */ | |
| 1331 | N_("Provides SSL support through GNUTLS."), | |
| 1332 | "Christian Hammond <chipx86@gnupdate.org>", | |
| 15884 | 1333 | PURPLE_WEBSITE, /**< homepage */ |
| 7016 | 1334 | |
| 1335 | plugin_load, /**< load */ | |
| 1336 | plugin_unload, /**< unload */ | |
| 1337 | NULL, /**< destroy */ | |
| 1338 | ||
| 1339 | NULL, /**< ui_info */ | |
|
11513
89bf8d856291
[gaim-migrate @ 13758]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11256
diff
changeset
|
1340 | NULL, /**< extra_info */ |
|
89bf8d856291
[gaim-migrate @ 13758]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11256
diff
changeset
|
1341 | NULL, /**< prefs_info */ |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1342 | NULL, /**< actions */ |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1343 | |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1344 | /* padding */ |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1345 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1346 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1347 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
1348 | NULL |
| 7016 | 1349 | }; |
| 1350 | ||
| 1351 | static void | |
| 15884 | 1352 | init_plugin(PurplePlugin *plugin) |
| 7016 | 1353 | { |
| 1354 | } | |
| 1355 | ||
| 15884 | 1356 | PURPLE_INIT_PLUGIN(ssl_gnutls, init_plugin, info) |