Mercurial > pidgin
annotate libpurple/plugins/ssl/ssl-nss.c @ 21173:726f91be55ed
merge of '8f4d756b61b5688ce770c469c3a7095dbe6c271d'
and 'b8fa91b64c41d38520d7944d70d627007e271158'
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Thu, 08 Nov 2007 19:50:22 +0000 |
parents | 3cc856ca2338 |
children | c38d72677c8a |
rev | line source |
---|---|
15373
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 * |
15822 | 4 * purple |
15373
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 |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19670
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
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:
17566
diff
changeset
|
24 #include "certificate.h" |
15373
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" |
19990
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
27 #include "util.h" |
15373
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 #ifdef HAVE_NSS |
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 #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
|
35 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 #include <nspr.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 #include <nss.h> |
19990
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
38 #include <nssb64.h> |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #include <pk11func.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #include <prio.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 #include <secerr.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 #include <secmod.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 #include <ssl.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 #include <sslerr.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 #include <sslproto.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 |
17566
016eee704a96
Avoid including NSPR's private header pprio.h just for the prototype of
Stu Tomlinson <stu@nosnilmot.com>
parents:
17514
diff
changeset
|
47 /* 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:
17514
diff
changeset
|
48 * 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:
17514
diff
changeset
|
49 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:
17514
diff
changeset
|
50 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 typedef struct |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 PRFileDesc *fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 PRFileDesc *in; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 guint handshake_handler; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
15822 | 57 } PurpleSslNssData; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 |
15822 | 59 #define PURPLE_SSL_NSS_DATA(gsc) ((PurpleSslNssData *)gsc->private_data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 static const PRIOMethods *_nss_methods = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 static PRDescIdentity _identity; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 /* Thank you, Evolution */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 set_errno(int code) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 /* FIXME: this should handle more. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 switch (code) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 case PR_INVALID_ARGUMENT_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 errno = EINVAL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 case PR_PENDING_INTERRUPT_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 errno = EINTR; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 case PR_IO_PENDING_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 errno = EAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 case PR_WOULD_BLOCK_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 errno = EAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 /*errno = EWOULDBLOCK; */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 case PR_IN_PROGRESS_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 errno = EINPROGRESS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 case PR_ALREADY_INITIATED_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 errno = EALREADY; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 case PR_NETWORK_UNREACHABLE_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 errno = EHOSTUNREACH; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 case PR_CONNECT_REFUSED_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 errno = ECONNREFUSED; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 case PR_CONNECT_TIMEOUT_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 case PR_IO_TIMEOUT_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 errno = ETIMEDOUT; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 case PR_NOT_CONNECTED_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 errno = ENOTCONN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 case PR_CONNECT_RESET_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 errno = ECONNRESET; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 case PR_IO_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 errno = EIO; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 break; |
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 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 |
19670
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
112 static gchar *get_error_text() |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
113 { |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
114 PRInt32 len = PR_GetErrorTextLength(); |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
115 gchar *ret = NULL; |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
116 |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
117 if (len > 0) { |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
118 ret = g_malloc(len + 1); |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
119 len = PR_GetErrorText(ret); |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
120 ret[len] = '\0'; |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
121 } |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
122 |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
123 return ret; |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
124 } |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
125 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 ssl_nss_init_nss(void) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 char *lib; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); |
16809
2a98d8b6095e
Proabably fixes ticket #578, it's the recommended way of initializing NSS
Stu Tomlinson <stu@nosnilmot.com>
parents:
16665
diff
changeset
|
131 NSS_NoDB_Init("."); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 /* 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
|
134 #ifndef _WIN32 |
16098 | 135 lib = g_strdup(LIBDIR "/libnssckbi.so"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 lib = g_strdup("nssckbi.dll"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 SECMOD_AddNewModule("Builtins", lib, 0, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 g_free(lib); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 NSS_SetDomesticPolicy(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 |
15822 | 143 _identity = PR_GetUniqueIdentity("Purple"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 _nss_methods = PR_GetDefaultIOMethods(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 static SECStatus |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 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
|
149 PRBool is_server) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 return SECSuccess; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 #if 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 CERTCertificate *cert; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 void *pinArg; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 SECStatus status; |
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 cert = SSL_PeerCertificate(socket); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 pinArg = SSL_RevealPinArg(socket); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 status = CERT_VerifyCertNow((CERTCertDBHandle *)arg, cert, checksig, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 certUsageSSLClient, pinArg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 if (status != SECSuccess) { |
15822 | 165 purple_debug_error("nss", "CERT_VerifyCertNow failed\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 CERT_DestroyCertificate(cert); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 return status; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 } |
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_DestroyCertificate(cert); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 return SECSuccess; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 static SECStatus |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 ssl_bad_cert(void *arg, PRFileDesc *socket) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 SECStatus status = SECFailure; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 PRErrorCode err; |
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 if (arg == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 return status; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 *(PRErrorCode *)arg = err = PORT_GetError(); |
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 switch (err) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 case SEC_ERROR_INVALID_AVA: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 case SEC_ERROR_INVALID_TIME: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 case SEC_ERROR_BAD_SIGNATURE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 case SEC_ERROR_EXPIRED_CERTIFICATE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 case SEC_ERROR_UNKNOWN_ISSUER: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 case SEC_ERROR_UNTRUSTED_CERT: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 case SEC_ERROR_CERT_VALID: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 case SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 case SEC_ERROR_CRL_EXPIRED: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 case SEC_ERROR_CRL_BAD_SIGNATURE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 case SEC_ERROR_EXTENSION_VALUE_INVALID: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 case SEC_ERROR_CA_CERT_INVALID: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 case SEC_ERROR_CERT_USAGES_INVALID: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 case SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 status = SECSuccess; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 status = SECFailure; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 |
15822 | 210 purple_debug_error("nss", "Bad certificate: %d\n", err); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 return status; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 ssl_nss_init(void) |
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 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 ssl_nss_uninit(void) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 PR_Cleanup(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 _nss_methods = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 } |
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 void |
15822 | 230 ssl_nss_handshake_cb(gpointer data, int fd, PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 { |
15822 | 232 PurpleSslConnection *gsc = (PurpleSslConnection *)data; |
233 PurpleSslNssData *nss_data = gsc->private_data; | |
15373
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 /* 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
|
236 * 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
|
237 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 if(SSL_ForceHandshake(nss_data->in) != SECSuccess) { |
19670
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
239 gchar *error_txt; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 set_errno(PR_GetError()); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 if (errno == EAGAIN || errno == EWOULDBLOCK) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 |
19670
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
244 error_txt = get_error_text(); |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
245 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:
19649
diff
changeset
|
246 g_free(error_txt); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 if (gsc->error_cb != NULL) |
15822 | 249 gsc->error_cb(gsc, PURPLE_SSL_HANDSHAKE_FAILED, gsc->connect_cb_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 |
15822 | 251 purple_ssl_close(gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 |
15822 | 256 purple_input_remove(nss_data->handshake_handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 nss_data->handshake_handler = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 gsc->connect_cb(gsc->connect_cb_data, gsc, cond); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 static void |
15822 | 263 ssl_nss_connect(PurpleSslConnection *gsc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 { |
15822 | 265 PurpleSslNssData *nss_data = g_new0(PurpleSslNssData, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 PRSocketOptionData socket_opt; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 gsc->private_data = nss_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 nss_data->fd = PR_ImportTCPSocket(gsc->fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 if (nss_data->fd == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 { |
15822 | 274 purple_debug_error("nss", "nss_data->fd == NULL!\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 if (gsc->error_cb != NULL) |
15822 | 277 gsc->error_cb(gsc, PURPLE_SSL_CONNECT_FAILED, gsc->connect_cb_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 |
15822 | 279 purple_ssl_close((PurpleSslConnection *)gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 socket_opt.option = PR_SockOpt_Nonblocking; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 socket_opt.value.non_blocking = PR_TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 |
19670
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
287 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:
19649
diff
changeset
|
288 gchar *error_txt = get_error_text(); |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
289 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:
19649
diff
changeset
|
290 g_free(error_txt); |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
291 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 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
|
294 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 if (nss_data->in == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 { |
15822 | 297 purple_debug_error("nss", "nss_data->in == NUL!\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 if (gsc->error_cb != NULL) |
15822 | 300 gsc->error_cb(gsc, PURPLE_SSL_CONNECT_FAILED, gsc->connect_cb_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 |
15822 | 302 purple_ssl_close((PurpleSslConnection *)gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 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
|
308 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
|
309 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 SSL_AuthCertificateHook(nss_data->in, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 (SSLAuthCertificate)ssl_auth_cert, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 (void *)CERT_GetDefaultCertDB()); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 SSL_BadCertHook(nss_data->in, (SSLBadCertHandler)ssl_bad_cert, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 if(gsc->host) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 SSL_SetURL(nss_data->in, gsc->host); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 #if 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 /* 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
|
320 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
|
321 SSL_HandshakeCallback(nss_data->in, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 (SSLHandshakeCallback) ssl_nss_handshake_cb, gsc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 SSL_ResetHandshake(nss_data->in, PR_FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 |
15822 | 326 nss_data->handshake_handler = purple_input_add(gsc->fd, |
327 PURPLE_INPUT_READ, ssl_nss_handshake_cb, gsc); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 |
15822 | 329 ssl_nss_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 static void |
15822 | 333 ssl_nss_close(PurpleSslConnection *gsc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 { |
15822 | 335 PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 if(!nss_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 |
17514
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:
16809
diff
changeset
|
340 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:
16809
diff
changeset
|
341 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:
16809
diff
changeset
|
342 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:
16809
diff
changeset
|
343 } 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:
16809
diff
changeset
|
344 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:
16809
diff
changeset
|
345 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:
16809
diff
changeset
|
346 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 if (nss_data->handshake_handler) |
15822 | 349 purple_input_remove(nss_data->handshake_handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 g_free(nss_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 gsc->private_data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 static size_t |
15822 | 356 ssl_nss_read(PurpleSslConnection *gsc, void *data, size_t len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 ssize_t ret; |
15822 | 359 PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 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
|
362 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 if (ret == -1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 set_errno(PR_GetError()); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
366 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 static size_t |
15822 | 370 ssl_nss_write(PurpleSslConnection *gsc, const void *data, size_t len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 ssize_t ret; |
15822 | 373 PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 if(!nss_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 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
|
379 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 if (ret == -1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 set_errno(PR_GetError()); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 return ret; |
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 |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
386 static GList * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
387 ssl_nss_peer_certs(PurpleSslConnection *gsc) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
388 { |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
389 #if 0 |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
390 PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); |
19670
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
391 CERTCertificate *cert; |
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
392 /* |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
393 GList *chain = NULL; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
394 void *pinArg; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
395 SECStatus status; |
19670
fb3b3e93b9ca
Attempt to display user readable error messages for NSS.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19649
diff
changeset
|
396 */ |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
397 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
398 /* TODO: this is a blind guess */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
399 cert = SSL_PeerCertificate(nss_data->fd); |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
400 |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
401 if (cert) |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
402 CERT_DestroyCertificate(cert); |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
403 #endif |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
404 |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
405 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
406 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
407 return NULL; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
408 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
409 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
410 /************************************************************************/ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
411 /* X.509 functionality */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
412 /************************************************************************/ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
413 static PurpleCertificateScheme x509_nss; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
414 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
415 /** Helpr macro to retrieve the NSS certdata from a PurpleCertificate */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
416 #define X509_NSS_DATA(pcrt) ( (CERTCertificate * ) (pcrt->data) ) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
417 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
418 /** Imports a PEM-formatted X.509 certificate from the specified file. |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
419 * @param filename Filename to import from. Format is PEM |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
420 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
421 * @return A newly allocated Certificate structure of the x509_gnutls scheme |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
422 */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
423 static PurpleCertificate * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
424 x509_import_from_file(const gchar *filename) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
425 { |
19273
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
426 gchar *rawcert; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
427 gsize len = 0; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
428 CERTCertificate *crt_dat; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
429 PurpleCertificate *crt; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
430 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
431 g_return_val_if_fail(filename, NULL); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
432 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
433 purple_debug_info("nss/x509", |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
434 "Loading certificate from %s\n", |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
435 filename); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
436 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
437 /* Load the raw data up */ |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
438 if (!g_file_get_contents(filename, |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
439 &rawcert, &len, |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
440 NULL)) { |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
441 purple_debug_error("nss/x509", "Unable to read certificate file.\n"); |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
442 return NULL; |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19991
diff
changeset
|
443 } |
19273
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
444 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
445 /* Decode the certificate */ |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
446 crt_dat = CERT_DecodeCertFromPackage(rawcert, len); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
447 g_free(rawcert); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
448 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
449 g_return_val_if_fail(crt_dat, NULL); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
450 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
451 crt = g_new0(PurpleCertificate, 1); |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
452 crt->scheme = &x509_nss; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
453 crt->data = crt_dat; |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
454 |
db42632ac756
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19272
diff
changeset
|
455 return crt; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
456 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
457 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
458 /** |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
459 * Exports a PEM-formatted X.509 certificate to the specified file. |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
460 * @param filename Filename to export to. Format will be PEM |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
461 * @param crt Certificate to export |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
462 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
463 * @return TRUE if success, otherwise FALSE |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
464 */ |
19990
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
465 /* 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:
19989
diff
changeset
|
466 "convert yon certificate to PEM format" function. */ |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
467 static gboolean |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
468 x509_export_certificate(const gchar *filename, PurpleCertificate *crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
469 { |
19990
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
470 CERTCertificate *crt_dat; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
471 SECItem *dercrt; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
472 gchar *b64crt; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
473 gchar *pemcrt; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
474 gboolean ret = FALSE; |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
475 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
476 g_return_val_if_fail(filename, FALSE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
477 g_return_val_if_fail(crt, FALSE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
478 g_return_val_if_fail(crt->scheme == &x509_nss, FALSE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
479 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
480 crt_dat = X509_NSS_DATA(crt); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
481 g_return_val_if_fail(crt_dat, FALSE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
482 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
483 purple_debug_info("nss/x509", |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
484 "Exporting certificate to %s\n", filename); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
485 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
486 /* First, use NSS voodoo to create a DER-formatted certificate */ |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
487 dercrt = SEC_ASN1EncodeItem(NULL, NULL, crt_dat, |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
488 SEC_ASN1_GET(SEC_SignedCertificateTemplate)); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
489 g_return_val_if_fail(dercrt != NULL, FALSE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
490 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
491 /* Now encode it to b64 */ |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
492 b64crt = NSSBase64_EncodeItem(NULL, NULL, 0, dercrt); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
493 SECITEM_FreeItem(dercrt, PR_TRUE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
494 g_return_val_if_fail(b64crt, FALSE); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
495 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
496 /* Wrap it in nice PEM header things */ |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
497 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:
19989
diff
changeset
|
498 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:
19989
diff
changeset
|
499 function; hence, we'll let NSPR free it. */ |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
500 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
501 /* Finally, dump the silly thing to a file. */ |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
502 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:
19989
diff
changeset
|
503 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
504 g_free(pemcrt); |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
505 |
47f2becb7a60
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19989
diff
changeset
|
506 return ret; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
507 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
508 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
509 static PurpleCertificate * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
510 x509_copy_certificate(PurpleCertificate *crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
511 { |
19069
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
512 CERTCertificate *crt_dat; |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
513 PurpleCertificate *newcrt; |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
514 |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
515 g_return_val_if_fail(crt, NULL); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
516 g_return_val_if_fail(crt->scheme == &x509_nss, NULL); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
517 |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
518 crt_dat = X509_NSS_DATA(crt); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
519 g_return_val_if_fail(crt_dat, NULL); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
520 |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
521 /* Create the certificate copy */ |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
522 newcrt = g_new0(PurpleCertificate, 1); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
523 newcrt->scheme = &x509_nss; |
19083
5b8035030053
- Comment on NSS's refcounting prowess
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19074
diff
changeset
|
524 /* NSS does refcounting automatically */ |
19069
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
525 newcrt->data = CERT_DupCertificate(crt_dat); |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
526 |
fcb3e4a2aa9a
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19068
diff
changeset
|
527 return newcrt; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
528 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
529 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
530 /** Frees a Certificate |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
531 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
532 * Destroys a Certificate's internal data structures and frees the pointer |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
533 * given. |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
534 * @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:
17566
diff
changeset
|
535 * if it is not of the correct CertificateScheme. Can be NULL |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
536 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
537 */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
538 static void |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
539 x509_destroy_certificate(PurpleCertificate * crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
540 { |
19070
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
541 CERTCertificate *crt_dat; |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
542 |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
543 g_return_if_fail(crt); |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
544 g_return_if_fail(crt->scheme == &x509_nss); |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
545 |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
546 crt_dat = X509_NSS_DATA(crt); |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
547 g_return_if_fail(crt_dat); |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
548 |
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
549 /* 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
|
550 /* NSS does refcounting automatically */ |
19070
7ccb5ab3e07e
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19069
diff
changeset
|
551 CERT_DestroyCertificate(crt_dat); |
19087
7fa5d10969f4
- x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19083
diff
changeset
|
552 |
7fa5d10969f4
- x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19083
diff
changeset
|
553 /* Delete the PurpleCertificate as well */ |
7fa5d10969f4
- x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19083
diff
changeset
|
554 g_free(crt); |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
555 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
556 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
557 /** Determines whether one certificate has been issued and signed by another |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
558 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
559 * @param crt Certificate to check the signature of |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
560 * @param issuer Issuer's certificate |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
561 * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
562 * @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:
17566
diff
changeset
|
563 * @TODO Modify this function to return a reason for invalidity? |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
564 */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
565 static gboolean |
19987
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
566 x509_signed_by(PurpleCertificate * crt, |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
567 PurpleCertificate * issuer) |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
568 { |
19991
401d1182d1dc
- Make x509_signed_by return TRUE indiscriminately so that other things
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19990
diff
changeset
|
569 return TRUE; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
570 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
571 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
572 static GByteArray * |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
573 x509_sha1sum(PurpleCertificate *crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
574 { |
19074
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
575 CERTCertificate *crt_dat; |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
576 size_t hashlen = 20; /* Size of an sha1sum */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
577 GByteArray *sha1sum; |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
578 SECItem *derCert; /* DER representation of the cert */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
579 SECStatus st; |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
580 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
581 g_return_val_if_fail(crt, NULL); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
582 g_return_val_if_fail(crt->scheme == &x509_nss, NULL); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
583 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
584 crt_dat = X509_NSS_DATA(crt); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
585 g_return_val_if_fail(crt_dat, NULL); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
586 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
587 /* Get the certificate DER representation */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
588 derCert = &(crt_dat->derCert); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
589 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
590 /* Make a hash! */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
591 sha1sum = g_byte_array_sized_new(hashlen); |
19631
578b3c67d52c
- ssl-nss now reports a certificate's sha1sum correctly
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19508
diff
changeset
|
592 /* 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
|
593 sha1sum->len = hashlen; |
578b3c67d52c
- ssl-nss now reports a certificate's sha1sum correctly
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19508
diff
changeset
|
594 |
19074
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
595 st = PK11_HashBuf(SEC_OID_SHA1, sha1sum->data, |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
596 derCert->data, derCert->len); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
597 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
598 /* Check for errors */ |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
599 if (st != SECSuccess) { |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
600 g_byte_array_free(sha1sum, TRUE); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
601 purple_debug_error("nss/x509", |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
602 "Error: hashing failed!\n"); |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
603 return NULL; |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
604 } |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
605 |
3004bfa0e846
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19073
diff
changeset
|
606 return sha1sum; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
607 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
608 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
609 static gchar * |
19987
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
610 x509_dn (PurpleCertificate *crt) |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
611 { |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
612 CERTCertificate *crt_dat; |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
613 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
614 g_return_val_if_fail(crt, NULL); |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
615 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:
19681
diff
changeset
|
616 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
617 crt_dat = X509_NSS_DATA(crt); |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
618 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:
19681
diff
changeset
|
619 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
620 return g_strdup(crt_dat->subjectName); |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
621 } |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
622 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
623 static gchar * |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
624 x509_issuer_dn (PurpleCertificate *crt) |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
625 { |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
626 CERTCertificate *crt_dat; |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
627 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
628 g_return_val_if_fail(crt, NULL); |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
629 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:
19681
diff
changeset
|
630 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
631 crt_dat = X509_NSS_DATA(crt); |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
632 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:
19681
diff
changeset
|
633 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
634 return g_strdup(crt_dat->subjectName); |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
635 } |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
636 |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
637 static gchar * |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
638 x509_common_name (PurpleCertificate *crt) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
639 { |
19071
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
640 CERTCertificate *crt_dat; |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
641 char *nss_cn; |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
642 gchar *ret_cn; |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
643 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
644 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
|
645 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
|
646 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
647 crt_dat = X509_NSS_DATA(crt); |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
648 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
|
649 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
650 /* Q: |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
651 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
|
652 return the new copy? |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
653 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
654 A: |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
655 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
|
656 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
|
657 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
|
658 that. |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
659 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
660 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
|
661 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
662 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
|
663 ret_cn = g_strdup(nss_cn); |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
664 PORT_Free(nss_cn); |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
665 |
d224a1e4b919
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19070
diff
changeset
|
666 return ret_cn; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
667 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
668 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
669 static gboolean |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
670 x509_check_name (PurpleCertificate *crt, const gchar *name) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
671 { |
19072
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
672 CERTCertificate *crt_dat; |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
673 SECStatus st; |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
674 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
675 g_return_val_if_fail(crt, FALSE); |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
676 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
|
677 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
678 crt_dat = X509_NSS_DATA(crt); |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
679 g_return_val_if_fail(crt_dat, FALSE); |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
680 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
681 st = CERT_VerifyCertName(crt_dat, name); |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
682 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
683 if (st == SECSuccess) { |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
684 return TRUE; |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
685 } |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
686 else if (st == SECFailure) { |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
687 return FALSE; |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
688 } |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
689 |
4bdf4ce3473b
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19071
diff
changeset
|
690 /* If we get here...bad things! */ |
19508
f0c3497e2ea6
- Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19273
diff
changeset
|
691 purple_debug_error("nss/x509", |
f0c3497e2ea6
- Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19273
diff
changeset
|
692 "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
|
693 "have.\n"); |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
694 return FALSE; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
695 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
696 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
697 static gboolean |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
698 x509_times (PurpleCertificate *crt, time_t *activation, time_t *expiration) |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
699 { |
19073
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
700 CERTCertificate *crt_dat; |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
701 PRTime nss_activ, nss_expir; |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
702 |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
703 g_return_val_if_fail(crt, FALSE); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
704 g_return_val_if_fail(crt->scheme == &x509_nss, FALSE); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
705 |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
706 crt_dat = X509_NSS_DATA(crt); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
707 g_return_val_if_fail(crt_dat, FALSE); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
708 |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
709 /* Extract the times into ugly PRTime thingies */ |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
710 /* TODO: Maybe this shouldn't throw an error? */ |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
711 g_return_val_if_fail( |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
712 SECSuccess == CERT_GetCertTimes(crt_dat, |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
713 &nss_activ, &nss_expir), |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
714 FALSE); |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
715 |
19989
4f870bb6d3e6
- Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
716 /* 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:
19987
diff
changeset
|
717 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:
19987
diff
changeset
|
718 the funny conversion. */ |
19073
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
719 if (activation) { |
19989
4f870bb6d3e6
- Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
720 *activation = nss_activ / 1000000; |
19073
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
721 } |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
722 if (expiration) { |
19989
4f870bb6d3e6
- Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19987
diff
changeset
|
723 *expiration = nss_expir / 1000000; |
19073
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
724 } |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
725 |
2156321c5482
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19072
diff
changeset
|
726 return TRUE; |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
727 } |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
728 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
729 static PurpleCertificateScheme x509_nss = { |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
730 "x509", /* Scheme name */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
731 N_("X.509 Certificates"), /* User-visible scheme name */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
732 x509_import_from_file, /* Certificate import function */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
733 x509_export_certificate, /* Certificate export function */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
734 x509_copy_certificate, /* Copy */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
735 x509_destroy_certificate, /* Destroy cert */ |
19987
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
736 x509_signed_by, /* Signed-by */ |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
737 x509_sha1sum, /* SHA1 fingerprint */ |
19987
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
738 x509_dn, /* Unique ID */ |
eda223b50bdc
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19681
diff
changeset
|
739 x509_issuer_dn, /* Issuer Unique ID */ |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
740 x509_common_name, /* Subject name */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
741 x509_check_name, /* Check subject name */ |
19649
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19631
diff
changeset
|
742 x509_times, /* Activation/Expiration time */ |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19631
diff
changeset
|
743 |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19631
diff
changeset
|
744 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19631
diff
changeset
|
745 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19631
diff
changeset
|
746 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19631
diff
changeset
|
747 NULL |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
748 }; |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
749 |
15822 | 750 static PurpleSslOps ssl_ops = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
752 ssl_nss_init, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
753 ssl_nss_uninit, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
754 ssl_nss_connect, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
755 ssl_nss_close, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
756 ssl_nss_read, |
16665
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
757 ssl_nss_write, |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
758 ssl_nss_peer_certs, |
16665
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
759 |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
760 /* padding */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
761 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
762 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
763 NULL |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
764 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
765 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
766 #endif /* HAVE_NSS */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
767 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
768 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
769 static gboolean |
15822 | 770 plugin_load(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 #ifdef HAVE_NSS |
15822 | 773 if (!purple_ssl_get_ops()) { |
774 purple_ssl_set_ops(&ssl_ops); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
775 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
776 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
777 /* 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
|
778 ssl_nss_init_nss(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
780 /* Register the X.509 functions we provide */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
781 purple_certificate_register_scheme(&x509_nss); |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
782 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
783 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
784 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
786 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
788 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
789 static gboolean |
15822 | 790 plugin_unload(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
791 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 #ifdef HAVE_NSS |
15822 | 793 if (purple_ssl_get_ops() == &ssl_ops) { |
794 purple_ssl_set_ops(NULL); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 } |
19068
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
796 |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
797 /* Unregister our X.509 functions */ |
9ac0fbb569a5
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17566
diff
changeset
|
798 purple_certificate_unregister_scheme(&x509_nss); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
801 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
802 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 |
15822 | 804 static PurplePluginInfo info = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 { |
15822 | 806 PURPLE_PLUGIN_MAGIC, |
807 PURPLE_MAJOR_VERSION, | |
808 PURPLE_MINOR_VERSION, | |
809 PURPLE_PLUGIN_STANDARD, /**< type */ | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 NULL, /**< ui_requirement */ |
15822 | 811 PURPLE_PLUGIN_FLAG_INVISIBLE, /**< flags */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 NULL, /**< dependencies */ |
15822 | 813 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 SSL_NSS_PLUGIN_ID, /**< id */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 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
|
817 DISPLAY_VERSION, /**< version */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 /** summary */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
819 N_("Provides SSL support through Mozilla NSS."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
820 /** description */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 N_("Provides SSL support through Mozilla NSS."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 "Christian Hammond <chipx86@gnupdate.org>", |
15822 | 823 PURPLE_WEBSITE, /**< homepage */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 plugin_load, /**< load */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 plugin_unload, /**< unload */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
827 NULL, /**< destroy */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 NULL, /**< ui_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 NULL, /**< extra_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
831 NULL, /**< prefs_info */ |
16665
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
832 NULL, /**< actions */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
833 |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
834 /* padding */ |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
835 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
836 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
837 NULL, |
6531f1a2e1d7
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16098
diff
changeset
|
838 NULL |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
839 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
841 static void |
15822 | 842 init_plugin(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
843 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
844 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 |
15822 | 846 PURPLE_INIT_PLUGIN(ssl_nss, init_plugin, info) |