Mercurial > pidgin.yaz
annotate libpurple/plugins/ssl/ssl-nss.c @ 26728:d06af7664a7a
merge of '6a70c2c1325aeb644bff8476f94c5a25f83044fb'
and 'd5a487de6cafd4f773a3cc1b9b08d6081771e9de'
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Wed, 22 Apr 2009 18:37:31 +0000 |
parents | ab5a49e46e38 |
children | 0491bd8a2a60 |
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 | 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; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 |
15823 | 55 } PurpleSslNssData; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
15823 | 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 | 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 | 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 | 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 | 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 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 PR_Cleanup(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 _nss_methods = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 } |
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 static void |
23799
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
244 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
|
245 gpointer userdata) |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
246 { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
247 PurpleSslConnection *gsc = (PurpleSslConnection *) userdata; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
248 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
249 if (st == PURPLE_CERTIFICATE_VALID) { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
250 /* 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
|
251 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
|
252 } else { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
253 /* Otherwise, signal an error */ |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
254 if(gsc->error_cb != NULL) |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
255 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
|
256 gsc->connect_cb_data); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
257 purple_ssl_close(gsc); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
258 } |
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 /** 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
|
262 * |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
263 * @param cert Certificate to transform |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
264 * @return A newly allocated Certificate |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
265 */ |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
266 static PurpleCertificate * |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
267 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
|
268 { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
269 /* New certificate to return */ |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
270 PurpleCertificate * crt; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
271 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
272 /* 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
|
273 crt = g_new0(PurpleCertificate, 1); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
274 crt->scheme = &x509_nss; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
275 crt->data = CERT_DupCertificate(cert); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
276 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
277 return crt; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
278 } |
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 static GList * |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
281 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
|
282 { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
283 CERTCertificate *curcert; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
284 CERTCertificate *issuerCert; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
285 PurpleCertificate * newcrt; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
286 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
287 /* 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
|
288 GList * peer_certs = NULL; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
289 int count; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
290 int64 now = PR_Now(); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
291 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
292 curcert = SSL_PeerCertificate(socket); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
293 if (curcert == NULL) { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
294 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
|
295 return NULL; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
296 } |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
297 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
304 if (curcert->isRoot) { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
305 break; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
306 } |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
307 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
|
308 if (!issuerCert) { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
309 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
|
310 break; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
311 } |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
312 CERT_DestroyCertificate(curcert); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
313 curcert = issuerCert; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
314 } |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
315 CERT_DestroyCertificate(curcert); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
316 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
317 return peer_certs; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
318 } |
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 static void |
15823 | 321 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
|
322 { |
15823 | 323 PurpleSslConnection *gsc = (PurpleSslConnection *)data; |
324 PurpleSslNssData *nss_data = gsc->private_data; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 /* 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
|
327 * 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
|
328 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 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
|
330 gchar *error_txt; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 set_errno(PR_GetError()); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 if (errno == EAGAIN || errno == EWOULDBLOCK) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 |
19669
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19648
diff
changeset
|
335 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
|
336 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
|
337 g_free(error_txt); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 if (gsc->error_cb != NULL) |
15823 | 340 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
|
341 |
15823 | 342 purple_ssl_close(gsc); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 |
15823 | 347 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
|
348 nss_data->handshake_handler = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 |
23799
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
350 /* 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
|
351 if (gsc->verifier) { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
352 GList *peers; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
353 /* 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
|
354 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
|
355 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
356 /* 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
|
357 purple_certificate_verify(gsc->verifier, |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
358 gsc->host, |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
359 peers, |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
360 ssl_nss_verified_cb, |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
361 gsc); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
362 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
363 purple_certificate_destroy_list(peers); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
364 } else { |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
365 /* 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
|
366 callback */ |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
367 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
|
368 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 } |
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 static void |
15823 | 372 ssl_nss_connect(PurpleSslConnection *gsc) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 { |
15823 | 374 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
|
375 PRSocketOptionData socket_opt; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 gsc->private_data = nss_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 nss_data->fd = PR_ImportTCPSocket(gsc->fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 if (nss_data->fd == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 { |
15823 | 383 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
|
384 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 if (gsc->error_cb != NULL) |
15823 | 386 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
|
387 |
15823 | 388 purple_ssl_close((PurpleSslConnection *)gsc); |
15374
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 return; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 socket_opt.option = PR_SockOpt_Nonblocking; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 socket_opt.value.non_blocking = PR_TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 |
19669
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19648
diff
changeset
|
396 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
|
397 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
|
398 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
|
399 g_free(error_txt); |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19648
diff
changeset
|
400 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 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
|
403 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 if (nss_data->in == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 { |
15823 | 406 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
|
407 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 if (gsc->error_cb != NULL) |
15823 | 409 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
|
410 |
15823 | 411 purple_ssl_close((PurpleSslConnection *)gsc); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 return; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 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
|
417 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
|
418 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 SSL_AuthCertificateHook(nss_data->in, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 (SSLAuthCertificate)ssl_auth_cert, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 (void *)CERT_GetDefaultCertDB()); |
23799
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
422 #if 0 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
423 /* 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
|
424 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
|
425 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 if(gsc->host) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 SSL_SetURL(nss_data->in, gsc->host); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 #if 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 /* 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
|
432 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
|
433 SSL_HandshakeCallback(nss_data->in, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 (SSLHandshakeCallback) ssl_nss_handshake_cb, gsc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 SSL_ResetHandshake(nss_data->in, PR_FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 |
15823 | 438 nss_data->handshake_handler = purple_input_add(gsc->fd, |
439 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
|
440 |
15823 | 441 ssl_nss_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ); |
15374
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 static void |
15823 | 445 ssl_nss_close(PurpleSslConnection *gsc) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 { |
15823 | 447 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
|
448 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 if(!nss_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 |
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
|
452 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
|
453 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
|
454 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
|
455 } 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
|
456 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
|
457 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
|
458 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 if (nss_data->handshake_handler) |
15823 | 461 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
|
462 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 g_free(nss_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 gsc->private_data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 static size_t |
15823 | 468 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
|
469 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 ssize_t ret; |
15823 | 471 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
|
472 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 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
|
474 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 if (ret == -1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 set_errno(PR_GetError()); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 static size_t |
15823 | 482 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
|
483 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 ssize_t ret; |
15823 | 485 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
|
486 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 if(!nss_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 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
|
491 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 if (ret == -1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 set_errno(PR_GetError()); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 return ret; |
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 |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
498 static GList * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
499 ssl_nss_peer_certs(PurpleSslConnection *gsc) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
500 { |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
501 #if 0 |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
502 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
|
503 CERTCertificate *cert; |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19648
diff
changeset
|
504 /* |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
505 GList *chain = NULL; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
506 void *pinArg; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
507 SECStatus status; |
19669
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19648
diff
changeset
|
508 */ |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
509 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
510 /* TODO: this is a blind guess */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
511 cert = SSL_PeerCertificate(nss_data->fd); |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
512 |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
513 if (cert) |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
514 CERT_DestroyCertificate(cert); |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
515 #endif |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
516 |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
517 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
518 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
519 return NULL; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
520 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
521 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
522 /************************************************************************/ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
523 /* X.509 functionality */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
524 /************************************************************************/ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
525 static PurpleCertificateScheme x509_nss; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
526 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
527 /** 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
|
528 #define X509_NSS_DATA(pcrt) ( (CERTCertificate * ) (pcrt->data) ) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
529 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
530 /** 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
|
531 * @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
|
532 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
533 * @return A newly allocated Certificate structure of the x509_gnutls scheme |
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 static PurpleCertificate * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
536 x509_import_from_file(const gchar *filename) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
537 { |
19273
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
538 gchar *rawcert; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
539 gsize len = 0; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
540 CERTCertificate *crt_dat; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
541 PurpleCertificate *crt; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
542 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
543 g_return_val_if_fail(filename, NULL); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
544 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
545 purple_debug_info("nss/x509", |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
546 "Loading certificate from %s\n", |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
547 filename); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
548 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
549 /* Load the raw data up */ |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
550 if (!g_file_get_contents(filename, |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
551 &rawcert, &len, |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
552 NULL)) { |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
553 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
|
554 return NULL; |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19989
diff
changeset
|
555 } |
19273
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
556 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
557 /* Decode the certificate */ |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
558 crt_dat = CERT_DecodeCertFromPackage(rawcert, len); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
559 g_free(rawcert); |
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 g_return_val_if_fail(crt_dat, NULL); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
562 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
563 crt = g_new0(PurpleCertificate, 1); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
564 crt->scheme = &x509_nss; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
565 crt->data = crt_dat; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
566 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
567 return crt; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
568 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
569 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
570 /** |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
571 * 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
|
572 * @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
|
573 * @param crt Certificate to export |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
574 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
575 * @return TRUE if success, otherwise FALSE |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
576 */ |
19988
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
577 /* 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
|
578 "convert yon certificate to PEM format" function. */ |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
579 static gboolean |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
580 x509_export_certificate(const gchar *filename, PurpleCertificate *crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
581 { |
19988
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
582 CERTCertificate *crt_dat; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
583 SECItem *dercrt; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
584 gchar *b64crt; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
585 gchar *pemcrt; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
586 gboolean ret = FALSE; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
587 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
588 g_return_val_if_fail(filename, FALSE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
589 g_return_val_if_fail(crt, FALSE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
590 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
|
591 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
592 crt_dat = X509_NSS_DATA(crt); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
593 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
|
594 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
595 purple_debug_info("nss/x509", |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
596 "Exporting certificate to %s\n", filename); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
597 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
598 /* 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
|
599 dercrt = SEC_ASN1EncodeItem(NULL, NULL, crt_dat, |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
600 SEC_ASN1_GET(SEC_SignedCertificateTemplate)); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
601 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
|
602 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
603 /* Now encode it to b64 */ |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
604 b64crt = NSSBase64_EncodeItem(NULL, NULL, 0, dercrt); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
605 SECITEM_FreeItem(dercrt, PR_TRUE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
606 g_return_val_if_fail(b64crt, FALSE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
607 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
608 /* Wrap it in nice PEM header things */ |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
609 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
|
610 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
|
611 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
|
612 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
613 /* 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
|
614 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
|
615 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
616 g_free(pemcrt); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
617 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
618 return ret; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
619 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
620 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
621 static PurpleCertificate * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
622 x509_copy_certificate(PurpleCertificate *crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
623 { |
19069
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
624 CERTCertificate *crt_dat; |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
625 PurpleCertificate *newcrt; |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
626 |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
627 g_return_val_if_fail(crt, NULL); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
628 g_return_val_if_fail(crt->scheme == &x509_nss, NULL); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
629 |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
630 crt_dat = X509_NSS_DATA(crt); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
631 g_return_val_if_fail(crt_dat, NULL); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
632 |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
633 /* Create the certificate copy */ |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
634 newcrt = g_new0(PurpleCertificate, 1); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
635 newcrt->scheme = &x509_nss; |
19083
5b8035030053
- Comment on NSS's refcounting prowess
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19074
diff
changeset
|
636 /* NSS does refcounting automatically */ |
19069
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
637 newcrt->data = CERT_DupCertificate(crt_dat); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
638 |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
639 return newcrt; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
640 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
641 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
642 /** Frees a Certificate |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
643 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
644 * 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
|
645 * given. |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
646 * @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
|
647 * 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
|
648 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
649 */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
650 static void |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
651 x509_destroy_certificate(PurpleCertificate * crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
652 { |
19070
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
653 CERTCertificate *crt_dat; |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
654 |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
655 g_return_if_fail(crt); |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
656 g_return_if_fail(crt->scheme == &x509_nss); |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
657 |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
658 crt_dat = X509_NSS_DATA(crt); |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
659 g_return_if_fail(crt_dat); |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
660 |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
661 /* 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
|
662 /* NSS does refcounting automatically */ |
19070
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
663 CERT_DestroyCertificate(crt_dat); |
19087
7fa5d10969f4
- x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19083
diff
changeset
|
664 |
7fa5d10969f4
- x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19083
diff
changeset
|
665 /* Delete the PurpleCertificate as well */ |
7fa5d10969f4
- x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19083
diff
changeset
|
666 g_free(crt); |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
667 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
668 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
669 /** 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
|
670 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
671 * @param crt Certificate to check the signature of |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
672 * @param issuer Issuer's certificate |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
673 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
674 * @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
|
675 * @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
|
676 */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
677 static gboolean |
19985
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
678 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
|
679 PurpleCertificate * issuer) |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
680 { |
23799
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
681 CERTCertificate *subjectCert; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
682 CERTCertificate *issuerCert; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
683 SECStatus st; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
684 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
685 issuerCert = X509_NSS_DATA(issuer); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
686 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
|
687 |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
688 subjectCert = X509_NSS_DATA(crt); |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
689 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
|
690 |
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
|
691 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
|
692 || 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
|
693 return FALSE; |
d7c62b220ed0
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22007
diff
changeset
|
694 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
|
695 return st == SECSuccess; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
696 } |
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 static GByteArray * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
699 x509_sha1sum(PurpleCertificate *crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
700 { |
19074
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
701 CERTCertificate *crt_dat; |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
702 size_t hashlen = 20; /* Size of an sha1sum */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
703 GByteArray *sha1sum; |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
704 SECItem *derCert; /* DER representation of the cert */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
705 SECStatus st; |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
706 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
707 g_return_val_if_fail(crt, NULL); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
708 g_return_val_if_fail(crt->scheme == &x509_nss, NULL); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
709 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
710 crt_dat = X509_NSS_DATA(crt); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
711 g_return_val_if_fail(crt_dat, NULL); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
712 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
713 /* Get the certificate DER representation */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
714 derCert = &(crt_dat->derCert); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
715 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
716 /* Make a hash! */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
717 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
|
718 /* 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
|
719 sha1sum->len = hashlen; |
578b3c67d52c
- ssl-nss now reports a certificate's sha1sum correctly
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19508
diff
changeset
|
720 |
19074
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
721 st = PK11_HashBuf(SEC_OID_SHA1, sha1sum->data, |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
722 derCert->data, derCert->len); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
723 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
724 /* Check for errors */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
725 if (st != SECSuccess) { |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
726 g_byte_array_free(sha1sum, TRUE); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
727 purple_debug_error("nss/x509", |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
728 "Error: hashing failed!\n"); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
729 return NULL; |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
730 } |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
731 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
732 return sha1sum; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
733 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
734 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
735 static gchar * |
19985
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
736 x509_dn (PurpleCertificate *crt) |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
737 { |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
738 CERTCertificate *crt_dat; |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
739 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
740 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
|
741 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
|
742 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
743 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
|
744 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
|
745 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
746 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
|
747 } |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
748 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
749 static gchar * |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
750 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
|
751 { |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
752 CERTCertificate *crt_dat; |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
753 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
754 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
|
755 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
|
756 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
757 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
|
758 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
|
759 |
24299
ab5a49e46e38
x509_issuer_dn() should return the certificate's issuer name, not the cert
Stu Tomlinson <stu@nosnilmot.com>
parents:
24236
diff
changeset
|
760 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
|
761 } |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
762 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
763 static gchar * |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
764 x509_common_name (PurpleCertificate *crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
765 { |
19071
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
766 CERTCertificate *crt_dat; |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
767 char *nss_cn; |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
768 gchar *ret_cn; |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
769 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
770 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
|
771 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
|
772 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
773 crt_dat = X509_NSS_DATA(crt); |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
774 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
|
775 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
776 /* Q: |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
777 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
|
778 return the new copy? |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
779 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
780 A: |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
781 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
|
782 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
|
783 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
|
784 that. |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
785 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
786 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
|
787 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
788 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
|
789 ret_cn = g_strdup(nss_cn); |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
790 PORT_Free(nss_cn); |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
791 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
792 return ret_cn; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
793 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
794 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
795 static gboolean |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
796 x509_check_name (PurpleCertificate *crt, const gchar *name) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
797 { |
19072
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
798 CERTCertificate *crt_dat; |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
799 SECStatus st; |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
800 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
801 g_return_val_if_fail(crt, FALSE); |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
802 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
|
803 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
804 crt_dat = X509_NSS_DATA(crt); |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
805 g_return_val_if_fail(crt_dat, FALSE); |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
806 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
807 st = CERT_VerifyCertName(crt_dat, name); |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
808 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
809 if (st == SECSuccess) { |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
810 return TRUE; |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
811 } |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
812 else if (st == SECFailure) { |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
813 return FALSE; |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
814 } |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
815 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
816 /* If we get here...bad things! */ |
19508
f0c3497e2ea6
- Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19273
diff
changeset
|
817 purple_debug_error("nss/x509", |
f0c3497e2ea6
- Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19273
diff
changeset
|
818 "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
|
819 "have.\n"); |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
820 return FALSE; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
821 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
822 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
823 static gboolean |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
824 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
|
825 { |
19073
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
826 CERTCertificate *crt_dat; |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
827 PRTime nss_activ, nss_expir; |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
828 |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
829 g_return_val_if_fail(crt, FALSE); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
830 g_return_val_if_fail(crt->scheme == &x509_nss, FALSE); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
831 |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
832 crt_dat = X509_NSS_DATA(crt); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
833 g_return_val_if_fail(crt_dat, FALSE); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
834 |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
835 /* Extract the times into ugly PRTime thingies */ |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
836 /* TODO: Maybe this shouldn't throw an error? */ |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
837 g_return_val_if_fail( |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
838 SECSuccess == CERT_GetCertTimes(crt_dat, |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
839 &nss_activ, &nss_expir), |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
840 FALSE); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
841 |
19987
4f870bb6d3e6
- Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19985
diff
changeset
|
842 /* 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
|
843 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
|
844 the funny conversion. */ |
19073
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
845 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
|
846 *activation = nss_activ / 1000000; |
19073
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
847 } |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
848 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
|
849 *expiration = nss_expir / 1000000; |
19073
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
850 } |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
851 |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
852 return TRUE; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
853 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
854 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
855 static PurpleCertificateScheme x509_nss = { |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
856 "x509", /* Scheme name */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
857 N_("X.509 Certificates"), /* User-visible scheme name */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
858 x509_import_from_file, /* Certificate import function */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
859 x509_export_certificate, /* Certificate export function */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
860 x509_copy_certificate, /* Copy */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
861 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
|
862 x509_signed_by, /* Signed-by */ |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
863 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
|
864 x509_dn, /* Unique ID */ |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
865 x509_issuer_dn, /* Issuer Unique ID */ |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
866 x509_common_name, /* Subject name */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
867 x509_check_name, /* Check subject name */ |
19648
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19630
diff
changeset
|
868 x509_times, /* Activation/Expiration time */ |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19630
diff
changeset
|
869 |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19630
diff
changeset
|
870 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19630
diff
changeset
|
871 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19630
diff
changeset
|
872 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19630
diff
changeset
|
873 NULL |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
874 }; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
875 |
15823 | 876 static PurpleSslOps ssl_ops = |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
877 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
878 ssl_nss_init, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
879 ssl_nss_uninit, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
880 ssl_nss_connect, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
881 ssl_nss_close, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
882 ssl_nss_read, |
16673
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
883 ssl_nss_write, |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
884 ssl_nss_peer_certs, |
16673
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
885 |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
886 /* padding */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
887 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
888 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
889 NULL |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
890 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
891 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
892 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
893 static gboolean |
15823 | 894 plugin_load(PurplePlugin *plugin) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
895 { |
15823 | 896 if (!purple_ssl_get_ops()) { |
897 purple_ssl_set_ops(&ssl_ops); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
898 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
899 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
900 /* 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
|
901 ssl_nss_init_nss(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
902 |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
903 /* Register the X.509 functions we provide */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
904 purple_certificate_register_scheme(&x509_nss); |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
905 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
906 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
907 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
908 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 static gboolean |
15823 | 910 plugin_unload(PurplePlugin *plugin) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
911 { |
15823 | 912 if (purple_ssl_get_ops() == &ssl_ops) { |
913 purple_ssl_set_ops(NULL); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 } |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
915 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
916 /* Unregister our X.509 functions */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17804
diff
changeset
|
917 purple_certificate_unregister_scheme(&x509_nss); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
918 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
920 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
921 |
15823 | 922 static PurplePluginInfo info = |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
923 { |
15823 | 924 PURPLE_PLUGIN_MAGIC, |
925 PURPLE_MAJOR_VERSION, | |
926 PURPLE_MINOR_VERSION, | |
927 PURPLE_PLUGIN_STANDARD, /**< type */ | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
928 NULL, /**< ui_requirement */ |
15823 | 929 PURPLE_PLUGIN_FLAG_INVISIBLE, /**< flags */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
930 NULL, /**< dependencies */ |
15823 | 931 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
933 SSL_NSS_PLUGIN_ID, /**< id */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
934 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
|
935 DISPLAY_VERSION, /**< version */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
936 /** summary */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 N_("Provides SSL support through Mozilla NSS."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 /** description */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 N_("Provides SSL support through Mozilla NSS."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 "Christian Hammond <chipx86@gnupdate.org>", |
15823 | 941 PURPLE_WEBSITE, /**< homepage */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 plugin_load, /**< load */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 plugin_unload, /**< unload */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 NULL, /**< destroy */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 NULL, /**< ui_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 NULL, /**< extra_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 NULL, /**< prefs_info */ |
16673
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
950 NULL, /**< actions */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
951 |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
952 /* padding */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
953 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
954 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
955 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
956 NULL |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 static void |
15823 | 960 init_plugin(PurplePlugin *plugin) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
962 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
963 |
15823 | 964 PURPLE_INIT_PLUGIN(ssl_nss, init_plugin, info) |