annotate libpurple/plugins/ssl/ssl-nss.c @ 31957:67c2d695e8d5

Move the PIN-change option into a separate PluginAction.
author andrew.victor@mxit.com
date Mon, 11 Apr 2011 22:16:34 +0000
parents a8cc50c2279f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file ssl-nss.c Mozilla NSS SSL plugin.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
4 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19669
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "debug.h"
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
24 #include "certificate.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "plugin.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "sslconn.h"
19988
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
27 #include "util.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "version.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #define SSL_NSS_PLUGIN_ID "ssl-nss"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #undef HAVE_LONG_LONG /* Make Mozilla less angry. If angry, Mozilla SMASH! */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include <nspr.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include <nss.h>
19988
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
36 #include <nssb64.h>
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include <pk11func.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #include <prio.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include <secerr.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include <secmod.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include <ssl.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include <sslerr.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 #include <sslproto.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44
17804
016eee704a96 Avoid including NSPR's private header pprio.h just for the prototype of
Stu Tomlinson <stu@nosnilmot.com>
parents: 17752
diff changeset
45 /* This is defined in NSPR's <private/pprio.h>, but to avoid including a
016eee704a96 Avoid including NSPR's private header pprio.h just for the prototype of
Stu Tomlinson <stu@nosnilmot.com>
parents: 17752
diff changeset
46 * private header we duplicate the prototype here */
016eee704a96 Avoid including NSPR's private header pprio.h just for the prototype of
Stu Tomlinson <stu@nosnilmot.com>
parents: 17752
diff changeset
47 NSPR_API(PRFileDesc*) PR_ImportTCPSocket(PRInt32 osfd);
016eee704a96 Avoid including NSPR's private header pprio.h just for the prototype of
Stu Tomlinson <stu@nosnilmot.com>
parents: 17752
diff changeset
48
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 typedef struct
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 PRFileDesc *fd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 PRFileDesc *in;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 guint handshake_handler;
30064
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
54 guint handshake_timer;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
55 } PurpleSslNssData;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
57 #define PURPLE_SSL_NSS_DATA(gsc) ((PurpleSslNssData *)gsc->private_data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 static const PRIOMethods *_nss_methods = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 static PRDescIdentity _identity;
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
61 static PurpleCertificateScheme x509_nss;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 /* Thank you, Evolution */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 set_errno(int code)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 /* FIXME: this should handle more. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 switch (code) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 case PR_INVALID_ARGUMENT_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 errno = EINVAL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 case PR_PENDING_INTERRUPT_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 errno = EINTR;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 case PR_IO_PENDING_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 errno = EAGAIN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 case PR_WOULD_BLOCK_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 errno = EAGAIN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 /*errno = EWOULDBLOCK; */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 case PR_IN_PROGRESS_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 errno = EINPROGRESS;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 case PR_ALREADY_INITIATED_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 errno = EALREADY;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 case PR_NETWORK_UNREACHABLE_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 errno = EHOSTUNREACH;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 case PR_CONNECT_REFUSED_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 errno = ECONNREFUSED;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 case PR_CONNECT_TIMEOUT_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 case PR_IO_TIMEOUT_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 errno = ETIMEDOUT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 case PR_NOT_CONNECTED_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 errno = ENOTCONN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 case PR_CONNECT_RESET_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 errno = ECONNRESET;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 case PR_IO_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 default:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 errno = EIO;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 21030
diff changeset
111 static gchar *get_error_text(void)
19669
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
112 {
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
113 PRInt32 len = PR_GetErrorTextLength();
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
114 gchar *ret = NULL;
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
115
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
116 if (len > 0) {
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
117 ret = g_malloc(len + 1);
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
118 len = PR_GetErrorText(ret);
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
119 ret[len] = '\0';
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
120 }
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
121
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
122 return ret;
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
123 }
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
124
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 ssl_nss_init_nss(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 char *lib;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
16820
2a98d8b6095e Proabably fixes ticket #578, it's the recommended way of initializing NSS
Stu Tomlinson <stu@nosnilmot.com>
parents: 16673
diff changeset
130 NSS_NoDB_Init(".");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 /* TODO: Fix this so autoconf does the work trying to find this lib. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 #ifndef _WIN32
16098
634b96915d2e Death to Binreloc\!
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
134 lib = g_strdup(LIBDIR "/libnssckbi.so");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 #else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 lib = g_strdup("nssckbi.dll");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 SECMOD_AddNewModule("Builtins", lib, 0, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 g_free(lib);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 NSS_SetDomesticPolicy();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141
24112
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
142 SSL_CipherPrefSetDefault(TLS_DHE_RSA_WITH_AES_256_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
143 SSL_CipherPrefSetDefault(TLS_DHE_DSS_WITH_AES_256_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
144 SSL_CipherPrefSetDefault(TLS_RSA_WITH_AES_256_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
145 SSL_CipherPrefSetDefault(TLS_DHE_DSS_WITH_RC4_128_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
146 SSL_CipherPrefSetDefault(TLS_DHE_RSA_WITH_AES_128_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
147 SSL_CipherPrefSetDefault(TLS_DHE_DSS_WITH_AES_128_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
148 SSL_CipherPrefSetDefault(SSL_RSA_WITH_RC4_128_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
149 SSL_CipherPrefSetDefault(TLS_RSA_WITH_AES_128_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
150 SSL_CipherPrefSetDefault(SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
151 SSL_CipherPrefSetDefault(SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
152 SSL_CipherPrefSetDefault(SSL_DHE_RSA_WITH_DES_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
153 SSL_CipherPrefSetDefault(SSL_DHE_DSS_WITH_DES_CBC_SHA, 1);
0006181485ea Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents: 24008
diff changeset
154
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
155 _identity = PR_GetUniqueIdentity("Purple");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 _nss_methods = PR_GetDefaultIOMethods();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 static SECStatus
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 ssl_auth_cert(void *arg, PRFileDesc *socket, PRBool checksig,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 PRBool is_server)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 return SECSuccess;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 CERTCertificate *cert;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 void *pinArg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 SECStatus status;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 cert = SSL_PeerCertificate(socket);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 pinArg = SSL_RevealPinArg(socket);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 status = CERT_VerifyCertNow((CERTCertDBHandle *)arg, cert, checksig,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 certUsageSSLClient, pinArg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 if (status != SECSuccess) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
177 purple_debug_error("nss", "CERT_VerifyCertNow failed\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 CERT_DestroyCertificate(cert);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 return status;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 CERT_DestroyCertificate(cert);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 return SECSuccess;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
187 #if 0
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 static SECStatus
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 ssl_bad_cert(void *arg, PRFileDesc *socket)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 SECStatus status = SECFailure;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 PRErrorCode err;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 if (arg == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 return status;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 *(PRErrorCode *)arg = err = PORT_GetError();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 switch (err)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 case SEC_ERROR_INVALID_AVA:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 case SEC_ERROR_INVALID_TIME:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 case SEC_ERROR_BAD_SIGNATURE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 case SEC_ERROR_EXPIRED_CERTIFICATE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 case SEC_ERROR_UNKNOWN_ISSUER:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 case SEC_ERROR_UNTRUSTED_CERT:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 case SEC_ERROR_CERT_VALID:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 case SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 case SEC_ERROR_CRL_EXPIRED:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 case SEC_ERROR_CRL_BAD_SIGNATURE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 case SEC_ERROR_EXTENSION_VALUE_INVALID:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 case SEC_ERROR_CA_CERT_INVALID:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 case SEC_ERROR_CERT_USAGES_INVALID:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 case SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 status = SECSuccess;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 default:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 status = SECFailure;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
223 purple_debug_error("nss", "Bad certificate: %d\n", err);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 return status;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 }
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
227 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 static gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 ssl_nss_init(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 ssl_nss_uninit(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 {
30065
fc4bacb35cbc nss: NSS should work after reiniting libpurple. Closes #11524.
Paul Aurich <paul@darkrain42.org>
parents: 30064
diff changeset
238 NSS_Shutdown();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 PR_Cleanup();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 _nss_methods = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 static void
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
245 ssl_nss_verified_cb(PurpleCertificateVerificationStatus st,
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
246 gpointer userdata)
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
247 {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
248 PurpleSslConnection *gsc = (PurpleSslConnection *) userdata;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
249
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
250 if (st == PURPLE_CERTIFICATE_VALID) {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
251 /* Certificate valid? Good! Do the connection! */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
252 gsc->connect_cb(gsc->connect_cb_data, gsc, PURPLE_INPUT_READ);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
253 } else {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
254 /* Otherwise, signal an error */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
255 if(gsc->error_cb != NULL)
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
256 gsc->error_cb(gsc, PURPLE_SSL_CERTIFICATE_INVALID,
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
257 gsc->connect_cb_data);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
258 purple_ssl_close(gsc);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
259 }
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
260 }
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
261
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
262 /** Transforms an NSS containing an X.509 certificate into a Certificate instance
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
263 *
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
264 * @param cert Certificate to transform
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
265 * @return A newly allocated Certificate
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
266 */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
267 static PurpleCertificate *
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
268 x509_import_from_nss(CERTCertificate* cert)
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
269 {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
270 /* New certificate to return */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
271 PurpleCertificate * crt;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
272
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
273 /* Allocate the certificate and load it with data */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
274 crt = g_new0(PurpleCertificate, 1);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
275 crt->scheme = &x509_nss;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
276 crt->data = CERT_DupCertificate(cert);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
277
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
278 return crt;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
279 }
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
280
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
281 static GList *
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
282 ssl_nss_get_peer_certificates(PRFileDesc *socket, PurpleSslConnection * gsc)
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
283 {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
284 CERTCertificate *curcert;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
285 CERTCertificate *issuerCert;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
286 PurpleCertificate * newcrt;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
287
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
288 /* List of Certificate instances to return */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
289 GList * peer_certs = NULL;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
290 int count;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
291 int64 now = PR_Now();
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
292
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
293 curcert = SSL_PeerCertificate(socket);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
294 if (curcert == NULL) {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
295 purple_debug_error("nss", "could not DupCertificate\n");
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
296 return NULL;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
297 }
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
298
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
299 for (count = 0 ; count < CERT_MAX_CERT_CHAIN ; count++) {
24008
67cb8706a2f2 Fix a NULL pointer deref in the NSS SSL implementation with certain self-signed
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23799
diff changeset
300 purple_debug_info("nss", "subject=%s issuer=%s\n", curcert->subjectName,
67cb8706a2f2 Fix a NULL pointer deref in the NSS SSL implementation with certain self-signed
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23799
diff changeset
301 curcert->issuerName ? curcert->issuerName : "(null)");
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
302 newcrt = x509_import_from_nss(curcert);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
303 peer_certs = g_list_append(peer_certs, newcrt);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
304
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
305 if (curcert->isRoot) {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
306 break;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
307 }
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
308 issuerCert = CERT_FindCertIssuer(curcert, now, certUsageSSLServer);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
309 if (!issuerCert) {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
310 purple_debug_error("nss", "partial certificate chain\n");
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
311 break;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
312 }
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
313 CERT_DestroyCertificate(curcert);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
314 curcert = issuerCert;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
315 }
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
316 CERT_DestroyCertificate(curcert);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
317
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
318 return peer_certs;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
319 }
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
320
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
321 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
322 ssl_nss_handshake_cb(gpointer data, int fd, PurpleInputCondition cond)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
324 PurpleSslConnection *gsc = (PurpleSslConnection *)data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
325 PurpleSslNssData *nss_data = gsc->private_data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 /* I don't think this the best way to do this...
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 * It seems to work because it'll eventually use the cached value
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 if(SSL_ForceHandshake(nss_data->in) != SECSuccess) {
19669
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
331 gchar *error_txt;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 set_errno(PR_GetError());
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 if (errno == EAGAIN || errno == EWOULDBLOCK)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335
19669
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
336 error_txt = get_error_text();
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
337 purple_debug_error("nss", "Handshake failed %s (%d)\n", error_txt ? error_txt : "", PR_GetError());
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
338 g_free(error_txt);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 if (gsc->error_cb != NULL)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
341 gsc->error_cb(gsc, PURPLE_SSL_HANDSHAKE_FAILED, gsc->connect_cb_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
343 purple_ssl_close(gsc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
348 purple_input_remove(nss_data->handshake_handler);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 nss_data->handshake_handler = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
351 /* If a Verifier was given, hand control over to it */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
352 if (gsc->verifier) {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
353 GList *peers;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
354 /* First, get the peer cert chain */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
355 peers = ssl_nss_get_peer_certificates(nss_data->in, gsc);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
356
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
357 /* Now kick off the verification process */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
358 purple_certificate_verify(gsc->verifier,
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
359 gsc->host,
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
360 peers,
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
361 ssl_nss_verified_cb,
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
362 gsc);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
363
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
364 purple_certificate_destroy_list(peers);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
365 } else {
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
366 /* Otherwise, just call the "connection complete"
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
367 callback */
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
368 gsc->connect_cb(gsc->connect_cb_data, gsc, cond);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
369 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371
30064
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
372 static gboolean
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
373 start_handshake_cb(gpointer data)
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
374 {
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
375 PurpleSslConnection *gsc = data;
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
376 PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc);
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
377
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
378 nss_data->handshake_timer = 0;
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
379
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
380 ssl_nss_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ);
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
381 return FALSE;
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
382 }
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
383
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
385 ssl_nss_connect(PurpleSslConnection *gsc)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
387 PurpleSslNssData *nss_data = g_new0(PurpleSslNssData, 1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 PRSocketOptionData socket_opt;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 gsc->private_data = nss_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 nss_data->fd = PR_ImportTCPSocket(gsc->fd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 if (nss_data->fd == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
396 purple_debug_error("nss", "nss_data->fd == NULL!\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 if (gsc->error_cb != NULL)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
399 gsc->error_cb(gsc, PURPLE_SSL_CONNECT_FAILED, gsc->connect_cb_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
401 purple_ssl_close((PurpleSslConnection *)gsc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 socket_opt.option = PR_SockOpt_Nonblocking;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 socket_opt.value.non_blocking = PR_TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408
19669
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
409 if (PR_SetSocketOption(nss_data->fd, &socket_opt) != PR_SUCCESS) {
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
410 gchar *error_txt = get_error_text();
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
411 purple_debug_warning("nss", "unable to set socket into non-blocking mode: %s (%d)\n", error_txt ? error_txt : "", PR_GetError());
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
412 g_free(error_txt);
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
413 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 nss_data->in = SSL_ImportFD(NULL, nss_data->fd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 if (nss_data->in == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
419 purple_debug_error("nss", "nss_data->in == NUL!\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 if (gsc->error_cb != NULL)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
422 gsc->error_cb(gsc, PURPLE_SSL_CONNECT_FAILED, gsc->connect_cb_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
424 purple_ssl_close((PurpleSslConnection *)gsc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 SSL_OptionSet(nss_data->in, SSL_SECURITY, PR_TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 SSL_OptionSet(nss_data->in, SSL_HANDSHAKE_AS_CLIENT, PR_TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 SSL_AuthCertificateHook(nss_data->in,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 (SSLAuthCertificate)ssl_auth_cert,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 (void *)CERT_GetDefaultCertDB());
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
435 #if 0
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
436 /* No point in hooking BadCert, since ssl_auth_cert always succeeds */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 SSL_BadCertHook(nss_data->in, (SSLBadCertHandler)ssl_bad_cert, NULL);
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
438 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 if(gsc->host)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 SSL_SetURL(nss_data->in, gsc->host);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 /* This seems like it'd the be the correct way to implement the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 nonblocking stuff, but it doesn't seem to work */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 SSL_HandshakeCallback(nss_data->in,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 (SSLHandshakeCallback) ssl_nss_handshake_cb, gsc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 SSL_ResetHandshake(nss_data->in, PR_FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
451 nss_data->handshake_handler = purple_input_add(gsc->fd,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
452 PURPLE_INPUT_READ, ssl_nss_handshake_cb, gsc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453
30064
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
454 nss_data->handshake_timer = purple_timeout_add(0, start_handshake_cb, gsc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
458 ssl_nss_close(PurpleSslConnection *gsc)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
460 PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 if(!nss_data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464
17752
278e22624ce5 A while ago, "Paranoid" emailed devel@p.i, having noticed that purple_ssl_close() closes the ssl fd twice. I meant to commit this fix sooner, but here it is.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16820
diff changeset
465 if (nss_data->in) {
278e22624ce5 A while ago, "Paranoid" emailed devel@p.i, having noticed that purple_ssl_close() closes the ssl fd twice. I meant to commit this fix sooner, but here it is.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16820
diff changeset
466 PR_Close(nss_data->in);
278e22624ce5 A while ago, "Paranoid" emailed devel@p.i, having noticed that purple_ssl_close() closes the ssl fd twice. I meant to commit this fix sooner, but here it is.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16820
diff changeset
467 gsc->fd = -1;
278e22624ce5 A while ago, "Paranoid" emailed devel@p.i, having noticed that purple_ssl_close() closes the ssl fd twice. I meant to commit this fix sooner, but here it is.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16820
diff changeset
468 } else if (nss_data->fd) {
278e22624ce5 A while ago, "Paranoid" emailed devel@p.i, having noticed that purple_ssl_close() closes the ssl fd twice. I meant to commit this fix sooner, but here it is.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16820
diff changeset
469 PR_Close(nss_data->fd);
278e22624ce5 A while ago, "Paranoid" emailed devel@p.i, having noticed that purple_ssl_close() closes the ssl fd twice. I meant to commit this fix sooner, but here it is.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16820
diff changeset
470 gsc->fd = -1;
278e22624ce5 A while ago, "Paranoid" emailed devel@p.i, having noticed that purple_ssl_close() closes the ssl fd twice. I meant to commit this fix sooner, but here it is.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16820
diff changeset
471 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 if (nss_data->handshake_handler)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
474 purple_input_remove(nss_data->handshake_handler);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475
30064
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
476 if (nss_data->handshake_timer)
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
477 purple_timeout_remove(nss_data->handshake_timer);
df9de37e0274 gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <paul@darkrain42.org>
parents: 30050
diff changeset
478
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 g_free(nss_data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 gsc->private_data = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 static size_t
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
484 ssl_nss_read(PurpleSslConnection *gsc, void *data, size_t len)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 ssize_t ret;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
487 PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 ret = PR_Read(nss_data->in, data, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 if (ret == -1)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 set_errno(PR_GetError());
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 static size_t
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
498 ssl_nss_write(PurpleSslConnection *gsc, const void *data, size_t len)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 ssize_t ret;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
501 PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 if(!nss_data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 ret = PR_Write(nss_data->in, data, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 if (ret == -1)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 set_errno(PR_GetError());
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
514 static GList *
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
515 ssl_nss_peer_certs(PurpleSslConnection *gsc)
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
516 {
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
517 #if 0
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
518 PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc);
19669
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
519 CERTCertificate *cert;
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
520 /*
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
521 GList *chain = NULL;
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
522 void *pinArg;
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
523 SECStatus status;
19669
fb3b3e93b9ca Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19648
diff changeset
524 */
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
525
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
526 /* TODO: this is a blind guess */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
527 cert = SSL_PeerCertificate(nss_data->fd);
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
528
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
529 if (cert)
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
530 CERT_DestroyCertificate(cert);
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
531 #endif
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
532
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
533
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
534
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
535 return NULL;
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
536 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
537
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
538 /************************************************************************/
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
539 /* X.509 functionality */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
540 /************************************************************************/
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
541 static PurpleCertificateScheme x509_nss;
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
542
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
543 /** Helpr macro to retrieve the NSS certdata from a PurpleCertificate */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
544 #define X509_NSS_DATA(pcrt) ( (CERTCertificate * ) (pcrt->data) )
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
545
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
546 /** Imports a PEM-formatted X.509 certificate from the specified file.
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
547 * @param filename Filename to import from. Format is PEM
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
548 *
30050
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
549 * @return A newly allocated Certificate structure of the x509_nss scheme
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
550 */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
551 static PurpleCertificate *
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
552 x509_import_from_file(const gchar *filename)
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
553 {
19273
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
554 gchar *rawcert;
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
555 gsize len = 0;
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
556 CERTCertificate *crt_dat;
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
557 PurpleCertificate *crt;
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
558
27643
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
559 g_return_val_if_fail(filename != NULL, NULL);
19273
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
560
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
561 purple_debug_info("nss/x509",
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
562 "Loading certificate from %s\n",
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
563 filename);
27643
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
564
19273
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
565 /* Load the raw data up */
20329
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
566 if (!g_file_get_contents(filename,
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
567 &rawcert, &len,
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
568 NULL)) {
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
569 purple_debug_error("nss/x509", "Unable to read certificate file.\n");
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
570 return NULL;
24ce4fcce5b0 applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents: 19989
diff changeset
571 }
19273
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
572
27643
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
573 if (len == 0) {
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
574 purple_debug_error("nss/x509",
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
575 "Certificate file has no contents!\n");
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
576 if (rawcert)
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
577 g_free(rawcert);
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
578 return NULL;
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
579 }
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
580
19273
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
581 /* Decode the certificate */
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
582 crt_dat = CERT_DecodeCertFromPackage(rawcert, len);
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
583 g_free(rawcert);
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
584
27643
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
585 g_return_val_if_fail(crt_dat != NULL, NULL);
199cf148cdf8 Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <paul@darkrain42.org>
parents: 27510
diff changeset
586
19273
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
587 crt = g_new0(PurpleCertificate, 1);
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
588 crt->scheme = &x509_nss;
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
589 crt->data = crt_dat;
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
590
19273
db42632ac756 - Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19272
diff changeset
591 return crt;
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
592 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
593
30050
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
594 /** Imports a number of PEM-formatted X.509 certificates from the specified file.
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
595 * @param filename Filename to import from. Format is PEM
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
596 *
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
597 * @return A GSList of newly allocated Certificate structures of the x509_nss scheme
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
598 */
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
599 static GSList *
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
600 x509_importcerts_from_file(const gchar *filename)
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
601 {
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
602 gchar *rawcert, *begin, *end;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
603 gsize len = 0;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
604 GSList *crts = NULL;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
605 CERTCertificate *crt_dat;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
606 PurpleCertificate *crt;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
607
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
608 g_return_val_if_fail(filename != NULL, NULL);
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
609
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
610 purple_debug_info("nss/x509",
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
611 "Loading certificate from %s\n",
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
612 filename);
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
613
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
614 /* Load the raw data up */
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
615 if (!g_file_get_contents(filename,
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
616 &rawcert, &len,
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
617 NULL)) {
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
618 purple_debug_error("nss/x509", "Unable to read certificate file.\n");
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
619 return NULL;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
620 }
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
621
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
622 if (len == 0) {
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
623 purple_debug_error("nss/x509",
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
624 "Certificate file has no contents!\n");
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
625 if (rawcert)
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
626 g_free(rawcert);
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
627 return NULL;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
628 }
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
629
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
630 begin = rawcert;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
631 while((end = strstr(begin, "-----END CERTIFICATE-----")) != NULL) {
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
632 end += sizeof("-----END CERTIFICATE-----")-1;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
633 /* Decode the certificate */
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
634 crt_dat = CERT_DecodeCertFromPackage(begin, (end-begin));
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
635
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
636 g_return_val_if_fail(crt_dat != NULL, NULL);
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
637
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
638 crt = g_new0(PurpleCertificate, 1);
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
639 crt->scheme = &x509_nss;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
640 crt->data = crt_dat;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
641 crts = g_slist_prepend(crts, crt);
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
642 begin = end;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
643 }
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
644 g_free(rawcert);
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
645
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
646 return crts;
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
647 }
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
648 /**
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
649 * Exports a PEM-formatted X.509 certificate to the specified file.
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
650 * @param filename Filename to export to. Format will be PEM
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
651 * @param crt Certificate to export
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
652 *
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
653 * @return TRUE if success, otherwise FALSE
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
654 */
19988
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
655 /* This function should not be so complicated, but NSS doesn't seem to have a
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
656 "convert yon certificate to PEM format" function. */
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
657 static gboolean
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
658 x509_export_certificate(const gchar *filename, PurpleCertificate *crt)
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
659 {
19988
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
660 CERTCertificate *crt_dat;
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
661 SECItem *dercrt;
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
662 gchar *b64crt;
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
663 gchar *pemcrt;
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
664 gboolean ret = FALSE;
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
665
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
666 g_return_val_if_fail(filename, FALSE);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
667 g_return_val_if_fail(crt, FALSE);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
668 g_return_val_if_fail(crt->scheme == &x509_nss, FALSE);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
669
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
670 crt_dat = X509_NSS_DATA(crt);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
671 g_return_val_if_fail(crt_dat, FALSE);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
672
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
673 purple_debug_info("nss/x509",
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
674 "Exporting certificate to %s\n", filename);
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
675
19988
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
676 /* First, use NSS voodoo to create a DER-formatted certificate */
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
677 dercrt = SEC_ASN1EncodeItem(NULL, NULL, crt_dat,
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
678 SEC_ASN1_GET(SEC_SignedCertificateTemplate));
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
679 g_return_val_if_fail(dercrt != NULL, FALSE);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
680
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
681 /* Now encode it to b64 */
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
682 b64crt = NSSBase64_EncodeItem(NULL, NULL, 0, dercrt);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
683 SECITEM_FreeItem(dercrt, PR_TRUE);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
684 g_return_val_if_fail(b64crt, FALSE);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
685
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
686 /* Wrap it in nice PEM header things */
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
687 pemcrt = g_strdup_printf("-----BEGIN CERTIFICATE-----\n%s\n-----END CERTIFICATE-----\n", b64crt);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
688 PORT_Free(b64crt); /* Notice that b64crt was allocated by an NSS
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
689 function; hence, we'll let NSPR free it. */
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
690
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
691 /* Finally, dump the silly thing to a file. */
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
692 ret = purple_util_write_data_to_file_absolute(filename, pemcrt, -1);
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
693
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
694 g_free(pemcrt);
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
695
19988
47f2becb7a60 - Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19987
diff changeset
696 return ret;
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
697 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
698
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
699 static PurpleCertificate *
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
700 x509_copy_certificate(PurpleCertificate *crt)
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
701 {
19069
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
702 CERTCertificate *crt_dat;
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
703 PurpleCertificate *newcrt;
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
704
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
705 g_return_val_if_fail(crt, NULL);
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
706 g_return_val_if_fail(crt->scheme == &x509_nss, NULL);
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
707
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
708 crt_dat = X509_NSS_DATA(crt);
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
709 g_return_val_if_fail(crt_dat, NULL);
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
710
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
711 /* Create the certificate copy */
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
712 newcrt = g_new0(PurpleCertificate, 1);
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
713 newcrt->scheme = &x509_nss;
19083
5b8035030053 - Comment on NSS's refcounting prowess
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19074
diff changeset
714 /* NSS does refcounting automatically */
19069
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
715 newcrt->data = CERT_DupCertificate(crt_dat);
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
716
19069
fcb3e4a2aa9a - x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19068
diff changeset
717 return newcrt;
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
718 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
719
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
720 /** Frees a Certificate
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
721 *
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
722 * Destroys a Certificate's internal data structures and frees the pointer
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
723 * given.
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
724 * @param crt Certificate instance to be destroyed. It WILL NOT be destroyed
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
725 * if it is not of the correct CertificateScheme. Can be NULL
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
726 *
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
727 */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
728 static void
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
729 x509_destroy_certificate(PurpleCertificate * crt)
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
730 {
19070
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
731 CERTCertificate *crt_dat;
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
732
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
733 g_return_if_fail(crt);
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
734 g_return_if_fail(crt->scheme == &x509_nss);
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
735
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
736 crt_dat = X509_NSS_DATA(crt);
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
737 g_return_if_fail(crt_dat);
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
738
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
739 /* Finally we have the certificate. So let's kill it */
19083
5b8035030053 - Comment on NSS's refcounting prowess
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19074
diff changeset
740 /* NSS does refcounting automatically */
19070
7ccb5ab3e07e - x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19069
diff changeset
741 CERT_DestroyCertificate(crt_dat);
19087
7fa5d10969f4 - x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19083
diff changeset
742
7fa5d10969f4 - x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19083
diff changeset
743 /* Delete the PurpleCertificate as well */
7fa5d10969f4 - x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19083
diff changeset
744 g_free(crt);
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
745 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
746
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
747 /** Determines whether one certificate has been issued and signed by another
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
748 *
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
749 * @param crt Certificate to check the signature of
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
750 * @param issuer Issuer's certificate
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
751 *
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
752 * @return TRUE if crt was signed and issued by issuer, otherwise FALSE
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
753 * @TODO Modify this function to return a reason for invalidity?
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
754 */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
755 static gboolean
19985
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
756 x509_signed_by(PurpleCertificate * crt,
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
757 PurpleCertificate * issuer)
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
758 {
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
759 CERTCertificate *subjectCert;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
760 CERTCertificate *issuerCert;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
761 SECStatus st;
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
762
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
763 issuerCert = X509_NSS_DATA(issuer);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
764 g_return_val_if_fail(issuerCert, FALSE);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
765
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
766 subjectCert = X509_NSS_DATA(crt);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
767 g_return_val_if_fail(subjectCert, FALSE);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
768
24008
67cb8706a2f2 Fix a NULL pointer deref in the NSS SSL implementation with certain self-signed
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23799
diff changeset
769 if (subjectCert->issuerName == NULL
67cb8706a2f2 Fix a NULL pointer deref in the NSS SSL implementation with certain self-signed
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23799
diff changeset
770 || PORT_Strcmp(subjectCert->issuerName, issuerCert->subjectName) != 0)
23799
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
771 return FALSE;
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
772 st = CERT_VerifySignedData(&subjectCert->signatureWrap, issuerCert, PR_Now(), NULL);
d7c62b220ed0 Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 22007
diff changeset
773 return st == SECSuccess;
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
774 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
775
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
776 static GByteArray *
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
777 x509_sha1sum(PurpleCertificate *crt)
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
778 {
19074
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
779 CERTCertificate *crt_dat;
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
780 size_t hashlen = 20; /* Size of an sha1sum */
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
781 GByteArray *sha1sum;
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
782 SECItem *derCert; /* DER representation of the cert */
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
783 SECStatus st;
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
784
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
785 g_return_val_if_fail(crt, NULL);
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
786 g_return_val_if_fail(crt->scheme == &x509_nss, NULL);
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
787
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
788 crt_dat = X509_NSS_DATA(crt);
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
789 g_return_val_if_fail(crt_dat, NULL);
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
790
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
791 /* Get the certificate DER representation */
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
792 derCert = &(crt_dat->derCert);
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
793
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
794 /* Make a hash! */
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
795 sha1sum = g_byte_array_sized_new(hashlen);
19630
578b3c67d52c - ssl-nss now reports a certificate's sha1sum correctly
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19508
diff changeset
796 /* glib leaves the size as 0 by default */
578b3c67d52c - ssl-nss now reports a certificate's sha1sum correctly
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19508
diff changeset
797 sha1sum->len = hashlen;
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
798
19074
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
799 st = PK11_HashBuf(SEC_OID_SHA1, sha1sum->data,
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
800 derCert->data, derCert->len);
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
801
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
802 /* Check for errors */
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
803 if (st != SECSuccess) {
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
804 g_byte_array_free(sha1sum, TRUE);
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
805 purple_debug_error("nss/x509",
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
806 "Error: hashing failed!\n");
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
807 return NULL;
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
808 }
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
809
3004bfa0e846 - x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19073
diff changeset
810 return sha1sum;
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
811 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
812
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
813 static gchar *
19985
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
814 x509_dn (PurpleCertificate *crt)
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
815 {
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
816 CERTCertificate *crt_dat;
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
817
19985
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
818 g_return_val_if_fail(crt, NULL);
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
819 g_return_val_if_fail(crt->scheme == &x509_nss, NULL);
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
820
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
821 crt_dat = X509_NSS_DATA(crt);
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
822 g_return_val_if_fail(crt_dat, NULL);
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
823
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
824 return g_strdup(crt_dat->subjectName);
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
825 }
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
826
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
827 static gchar *
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
828 x509_issuer_dn (PurpleCertificate *crt)
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
829 {
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
830 CERTCertificate *crt_dat;
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
831
19985
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
832 g_return_val_if_fail(crt, NULL);
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
833 g_return_val_if_fail(crt->scheme == &x509_nss, NULL);
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
834
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
835 crt_dat = X509_NSS_DATA(crt);
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
836 g_return_val_if_fail(crt_dat, NULL);
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
837
24299
ab5a49e46e38 x509_issuer_dn() should return the certificate's issuer name, not the cert
Stu Tomlinson <stu@nosnilmot.com>
parents: 24236
diff changeset
838 return g_strdup(crt_dat->issuerName);
19985
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
839 }
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
840
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
841 static gchar *
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
842 x509_common_name (PurpleCertificate *crt)
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
843 {
19071
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
844 CERTCertificate *crt_dat;
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
845 char *nss_cn;
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
846 gchar *ret_cn;
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
847
19071
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
848 g_return_val_if_fail(crt, NULL);
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
849 g_return_val_if_fail(crt->scheme == &x509_nss, NULL);
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
850
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
851 crt_dat = X509_NSS_DATA(crt);
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
852 g_return_val_if_fail(crt_dat, NULL);
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
853
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
854 /* Q:
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
855 Why get a newly allocated string out of NSS, strdup it, and then
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
856 return the new copy?
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
857
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
858 A:
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
859 The NSS LXR docs state that I should use the NSPR free functions on
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
860 the strings that the NSS cert functions return. Since the libpurple
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
861 API expects a g_free()-able string, we make our own copy and return
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
862 that.
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
863
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
864 NSPR is something of a prima donna. */
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
865
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
866 nss_cn = CERT_GetCommonName( &(crt_dat->subject) );
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
867 ret_cn = g_strdup(nss_cn);
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
868 PORT_Free(nss_cn);
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
869
d224a1e4b919 - x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19070
diff changeset
870 return ret_cn;
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
871 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
872
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
873 static gboolean
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
874 x509_check_name (PurpleCertificate *crt, const gchar *name)
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
875 {
19072
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
876 CERTCertificate *crt_dat;
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
877 SECStatus st;
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
878
19072
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
879 g_return_val_if_fail(crt, FALSE);
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
880 g_return_val_if_fail(crt->scheme == &x509_nss, FALSE);
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
881
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
882 crt_dat = X509_NSS_DATA(crt);
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
883 g_return_val_if_fail(crt_dat, FALSE);
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
884
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
885 st = CERT_VerifyCertName(crt_dat, name);
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
886
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
887 if (st == SECSuccess) {
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
888 return TRUE;
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
889 }
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
890 else if (st == SECFailure) {
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
891 return FALSE;
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
892 }
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
893
19072
4bdf4ce3473b - ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19071
diff changeset
894 /* If we get here...bad things! */
19508
f0c3497e2ea6 - Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19273
diff changeset
895 purple_debug_error("nss/x509",
f0c3497e2ea6 - Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19273
diff changeset
896 "x509_check_name fell through where it shouldn't "
f0c3497e2ea6 - Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19273
diff changeset
897 "have.\n");
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
898 return FALSE;
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
899 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
900
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
901 static gboolean
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
902 x509_times (PurpleCertificate *crt, time_t *activation, time_t *expiration)
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
903 {
19073
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
904 CERTCertificate *crt_dat;
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
905 PRTime nss_activ, nss_expir;
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
906
19073
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
907 g_return_val_if_fail(crt, FALSE);
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
908 g_return_val_if_fail(crt->scheme == &x509_nss, FALSE);
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
909
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
910 crt_dat = X509_NSS_DATA(crt);
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
911 g_return_val_if_fail(crt_dat, FALSE);
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
912
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
913 /* Extract the times into ugly PRTime thingies */
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
914 /* TODO: Maybe this shouldn't throw an error? */
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
915 g_return_val_if_fail(
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
916 SECSuccess == CERT_GetCertTimes(crt_dat,
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
917 &nss_activ, &nss_expir),
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
918 FALSE);
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
919
19987
4f870bb6d3e6 - Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19985
diff changeset
920 /* NSS's native PRTime type *almost* corresponds to time_t; however,
4f870bb6d3e6 - Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19985
diff changeset
921 it measures *microseconds* since the epoch, not seconds. Hence
4f870bb6d3e6 - Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19985
diff changeset
922 the funny conversion. */
19073
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
923 if (activation) {
19987
4f870bb6d3e6 - Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19985
diff changeset
924 *activation = nss_activ / 1000000;
19073
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
925 }
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
926 if (expiration) {
19987
4f870bb6d3e6 - Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19985
diff changeset
927 *expiration = nss_expir / 1000000;
19073
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
928 }
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30065
diff changeset
929
19073
2156321c5482 - x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19072
diff changeset
930 return TRUE;
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
931 }
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
932
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
933 static PurpleCertificateScheme x509_nss = {
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
934 "x509", /* Scheme name */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
935 N_("X.509 Certificates"), /* User-visible scheme name */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
936 x509_import_from_file, /* Certificate import function */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
937 x509_export_certificate, /* Certificate export function */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
938 x509_copy_certificate, /* Copy */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
939 x509_destroy_certificate, /* Destroy cert */
19985
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
940 x509_signed_by, /* Signed-by */
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
941 x509_sha1sum, /* SHA1 fingerprint */
19985
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
942 x509_dn, /* Unique ID */
eda223b50bdc - Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19680
diff changeset
943 x509_issuer_dn, /* Issuer Unique ID */
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
944 x509_common_name, /* Subject name */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
945 x509_check_name, /* Check subject name */
19648
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19630
diff changeset
946 x509_times, /* Activation/Expiration time */
30050
c35fd54ec64b Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <stu@nosnilmot.com>
parents: 27998
diff changeset
947 x509_importcerts_from_file, /* Multiple certificate import function */
19648
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19630
diff changeset
948
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19630
diff changeset
949 NULL,
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19630
diff changeset
950 NULL,
450f4a3c4c0f - Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents: 19630
diff changeset
951 NULL
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
952 };
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
953
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
954 static PurpleSslOps ssl_ops =
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 ssl_nss_init,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 ssl_nss_uninit,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 ssl_nss_connect,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 ssl_nss_close,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 ssl_nss_read,
16673
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
961 ssl_nss_write,
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
962 ssl_nss_peer_certs,
16673
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
963
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
964 /* padding */
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
965 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
966 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
967 NULL
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 static gboolean
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
972 plugin_load(PurplePlugin *plugin)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
974 if (!purple_ssl_get_ops()) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
975 purple_ssl_set_ops(&ssl_ops);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 /* Init NSS now, so others can use it even if sslconn never does */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 ssl_nss_init_nss();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
981 /* Register the X.509 functions we provide */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
982 purple_certificate_register_scheme(&x509_nss);
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
983
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 static gboolean
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
988 plugin_unload(PurplePlugin *plugin)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
990 if (purple_ssl_get_ops() == &ssl_ops) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
991 purple_ssl_set_ops(NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 }
19068
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
993
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
994 /* Unregister our X.509 functions */
9ac0fbb569a5 - Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17804
diff changeset
995 purple_certificate_unregister_scheme(&x509_nss);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1000 static PurplePluginInfo info =
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1002 PURPLE_PLUGIN_MAGIC,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1003 PURPLE_MAJOR_VERSION,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1004 PURPLE_MINOR_VERSION,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1005 PURPLE_PLUGIN_STANDARD, /**< type */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 NULL, /**< ui_requirement */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1007 PURPLE_PLUGIN_FLAG_INVISIBLE, /**< flags */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 NULL, /**< dependencies */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1009 PURPLE_PRIORITY_DEFAULT, /**< priority */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 SSL_NSS_PLUGIN_ID, /**< id */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 N_("NSS"), /**< name */
21030
3cc856ca2338 Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents: 20329
diff changeset
1013 DISPLAY_VERSION, /**< version */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 /** summary */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 N_("Provides SSL support through Mozilla NSS."),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 /** description */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017 N_("Provides SSL support through Mozilla NSS."),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 "Christian Hammond <chipx86@gnupdate.org>",
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1019 PURPLE_WEBSITE, /**< homepage */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021 plugin_load, /**< load */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 plugin_unload, /**< unload */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 NULL, /**< destroy */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 NULL, /**< ui_info */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 NULL, /**< extra_info */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 NULL, /**< prefs_info */
16673
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
1028 NULL, /**< actions */
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
1029
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
1030 /* padding */
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
1031 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
1032 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
1033 NULL,
6531f1a2e1d7 Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
1034 NULL
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1038 init_plugin(PurplePlugin *plugin)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1042 PURPLE_INIT_PLUGIN(ssl_nss, init_plugin, info)