Wed, 05 Nov 2014 00:09:52 -0500
Update NSS Default Cipher suites
* Use Firefox as a base reference, include some previously used stuff and enable various PFS certificates
* The following certificates were previously enabled (when using NSS 3.17.1)
and are no longer enabled:
* Various using RC2 and MD5
* TLS_DHE_DSS_WITH_AES_256_CBC_SHA
* TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
* TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
* TLS_DHE_DSS_WITH_RC4_128_SHA
* TLS_RSA_WITH_3DES_EDE_CBC_SHA
* TLS_RSA_WITH_RC4_128_SHA (this is probably the most controversial removal)
* TLS_RSA_WITH_RC4_128_MD5
* TLS_DHE_RSA_WITH_DES_CBC_SHA
* TLS_DHE_DSS_WITH_DES_CBC_SHA
Refs #8062, Fixes #16262
| 7016 | 1 | /** |
| 2 | * @file ssl-nss.c Mozilla NSS SSL plugin. | |
| 3 | * | |
| 15884 | 4 | * purple |
| 7016 | 5 | * |
| 6 | * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19847
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7016 | 21 | */ |
| 22 | #include "internal.h" | |
|
7051
8ddb8f560399
[gaim-migrate @ 7614]
Christian Hammond <chipx86@chipx86.com>
parents:
7050
diff
changeset
|
23 | #include "debug.h" |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
24 | #include "certificate.h" |
| 7016 | 25 | #include "plugin.h" |
|
7051
8ddb8f560399
[gaim-migrate @ 7614]
Christian Hammond <chipx86@chipx86.com>
parents:
7050
diff
changeset
|
26 | #include "sslconn.h" |
|
19983
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
27 | #include "util.h" |
| 9943 | 28 | #include "version.h" |
| 7016 | 29 | |
|
7029
fe690e0607ec
[gaim-migrate @ 7592]
Christian Hammond <chipx86@chipx86.com>
parents:
7028
diff
changeset
|
30 | #define SSL_NSS_PLUGIN_ID "ssl-nss" |
| 7016 | 31 | |
|
34242
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
32 | #ifdef _WIN32 |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
33 | # ifndef HAVE_LONG_LONG |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
34 | #define HAVE_LONG_LONG |
|
36160
d13511faaeec
Update NSS to 3.17.1 for the windows build
Daniel Atallah <datallah@pidgin.im>
parents:
36157
diff
changeset
|
35 | /* WINDDK_BUILD is defined because the checks around usage of |
|
d13511faaeec
Update NSS to 3.17.1 for the windows build
Daniel Atallah <datallah@pidgin.im>
parents:
36157
diff
changeset
|
36 | * intrisic functions are wrong in nspr */ |
|
d13511faaeec
Update NSS to 3.17.1 for the windows build
Daniel Atallah <datallah@pidgin.im>
parents:
36157
diff
changeset
|
37 | #define WINDDK_BUILD |
|
34242
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
38 | # endif |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
39 | #else |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
40 | /* TODO: Why is this done? |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
41 | * This is probably being overridden by <nspr.h> (prcpucfg.h) on *nix OSes */ |
|
9582
68facdf2b52d
[gaim-migrate @ 10425]
Christian Hammond <chipx86@chipx86.com>
parents:
8749
diff
changeset
|
42 | #undef HAVE_LONG_LONG /* Make Mozilla less angry. If angry, Mozilla SMASH! */ |
|
34242
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
43 | #endif |
|
9582
68facdf2b52d
[gaim-migrate @ 10425]
Christian Hammond <chipx86@chipx86.com>
parents:
8749
diff
changeset
|
44 | |
| 7016 | 45 | #include <nspr.h> |
| 46 | #include <nss.h> | |
|
19983
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
47 | #include <nssb64.h> |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
48 | #include <ocsp.h> |
| 7016 | 49 | #include <pk11func.h> |
| 50 | #include <prio.h> | |
| 51 | #include <secerr.h> | |
| 52 | #include <secmod.h> | |
| 53 | #include <ssl.h> | |
| 54 | #include <sslerr.h> | |
| 55 | #include <sslproto.h> | |
| 56 | ||
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
57 | /* There's a bug in some versions of this header that requires that some of |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
58 | the headers above be included first. This is true for at least libnss |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
59 | 3.15.4. */ |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
60 | #include <certdb.h> |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
61 | |
|
17673
efba6798f37e
Avoid including NSPR's private header pprio.h just for the prototype of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17623
diff
changeset
|
62 | /* This is defined in NSPR's <private/pprio.h>, but to avoid including a |
|
efba6798f37e
Avoid including NSPR's private header pprio.h just for the prototype of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17623
diff
changeset
|
63 | * private header we duplicate the prototype here */ |
|
efba6798f37e
Avoid including NSPR's private header pprio.h just for the prototype of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17623
diff
changeset
|
64 | NSPR_API(PRFileDesc*) PR_ImportTCPSocket(PRInt32 osfd); |
|
efba6798f37e
Avoid including NSPR's private header pprio.h just for the prototype of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17623
diff
changeset
|
65 | |
| 7016 | 66 | typedef struct |
| 67 | { | |
| 68 | PRFileDesc *fd; | |
| 69 | PRFileDesc *in; | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
70 | guint handshake_handler; |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
71 | guint handshake_timer; |
| 15884 | 72 | } PurpleSslNssData; |
| 7016 | 73 | |
| 15884 | 74 | #define PURPLE_SSL_NSS_DATA(gsc) ((PurpleSslNssData *)gsc->private_data) |
| 7016 | 75 | |
| 76 | static const PRIOMethods *_nss_methods = NULL; | |
| 77 | static PRDescIdentity _identity; | |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
78 | static PurpleCertificateScheme x509_nss; |
| 7016 | 79 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
80 | /* Thank you, Evolution */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
81 | static void |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
82 | set_errno(int code) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
83 | { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
84 | /* FIXME: this should handle more. */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
85 | switch (code) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
86 | case PR_INVALID_ARGUMENT_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
87 | errno = EINVAL; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
88 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
89 | case PR_PENDING_INTERRUPT_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
90 | errno = EINTR; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
91 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
92 | case PR_IO_PENDING_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
93 | errno = EAGAIN; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
94 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
95 | case PR_WOULD_BLOCK_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
96 | errno = EAGAIN; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
97 | /*errno = EWOULDBLOCK; */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
98 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
99 | case PR_IN_PROGRESS_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
100 | errno = EINPROGRESS; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
101 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
102 | case PR_ALREADY_INITIATED_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
103 | errno = EALREADY; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
104 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
105 | case PR_NETWORK_UNREACHABLE_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
106 | errno = EHOSTUNREACH; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
107 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
108 | case PR_CONNECT_REFUSED_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
109 | errno = ECONNREFUSED; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
110 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
111 | case PR_CONNECT_TIMEOUT_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
112 | case PR_IO_TIMEOUT_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
113 | errno = ETIMEDOUT; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
114 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
115 | case PR_NOT_CONNECTED_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
116 | errno = ENOTCONN; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
117 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
118 | case PR_CONNECT_RESET_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
119 | errno = ECONNRESET; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
120 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
121 | case PR_IO_ERROR: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
122 | default: |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
123 | errno = EIO; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
124 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
125 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
126 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
127 | |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20288
diff
changeset
|
128 | static gchar *get_error_text(void) |
|
19847
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
129 | { |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
130 | PRInt32 len = PR_GetErrorTextLength(); |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
131 | gchar *ret = NULL; |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
132 | |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
133 | if (len > 0) { |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
134 | ret = g_malloc(len + 1); |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
135 | len = PR_GetErrorText(ret); |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
136 | ret[len] = '\0'; |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
137 | } |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
138 | |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
139 | return ret; |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
140 | } |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
141 | |
|
36220
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
142 | static const PRUint16 default_ciphers[] = { |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
143 | #if NSS_VMAJOR > 3 || ( NSS_VMAJOR == 3 && NSS_VMINOR > 15 ) \ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
144 | || ( NSS_VMAJOR == 3 && NSS_VMINOR == 15 && NSS_VPATCH >= 1 ) |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
145 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
146 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
147 | TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
148 | # if NSS_VMAJOR > 3 || ( NSS_VMAJOR == 3 && NSS_VMINOR > 15 ) \ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
149 | || ( NSS_VMAJOR == 3 && NSS_VMINOR == 15 && NSS_VPATCH >= 2 ) |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
150 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
151 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
152 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
153 | # endif |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
154 | #endif |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
155 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
156 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
157 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
158 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
159 | TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
160 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
161 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
162 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
163 | TLS_DHE_RSA_WITH_AES_256_CBC_SHA, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
164 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
165 | TLS_DHE_DSS_WITH_AES_128_CBC_SHA, /* deprecated (DSS) */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
166 | /* TLS_DHE_DSS_WITH_AES_256_CBC_SHA, false }, // deprecated (DSS) */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
167 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
168 | TLS_ECDHE_RSA_WITH_RC4_128_SHA, /* deprecated (RC4) */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
169 | TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, /* deprecated (RC4) */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
170 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
171 | /* RFC 6120 Mandatory */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
172 | TLS_RSA_WITH_AES_128_CBC_SHA, /* deprecated (RSA key exchange) */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
173 | TLS_RSA_WITH_AES_256_CBC_SHA, /* deprecated (RSA key exchange) */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
174 | /* TLS_RSA_WITH_3DES_EDE_CBC_SHA, deprecated (RSA key exchange, 3DES) */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
175 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
176 | 0 /* end marker */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
177 | }; |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
178 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
179 | /* It's unfortunate we need to manage these manually, |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
180 | * ideally NSS would choose good defaults. |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
181 | * This is mostly based on FireFox's list: |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
182 | * https://hg.mozilla.org/mozilla-central/log/default/security/manager/ssl/src/nsNSSComponent.cpp */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
183 | static void ssl_nss_init_ciphers(void) { |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
184 | /* Disable any ciphers that NSS might have enabled by default */ |
|
36209
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
185 | const PRUint16 *cipher; |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
186 | for (cipher = SSL_GetImplementedCiphers(); *cipher != 0; ++cipher) { |
|
36220
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
187 | SSL_CipherPrefSetDefault(*cipher, PR_FALSE); |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
188 | } |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
189 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
190 | /* Now only set SSL/TLS ciphers we knew about at compile time */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
191 | for (cipher = default_ciphers; *cipher != 0; ++cipher) { |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
192 | SSL_CipherPrefSetDefault(*cipher, PR_TRUE); |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
193 | } |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
194 | |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
195 | /* Now log the available and enabled Ciphers */ |
|
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
196 | for (cipher = SSL_GetImplementedCiphers(); *cipher != 0; ++cipher) { |
|
36209
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
197 | const PRUint16 suite = *cipher; |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
198 | SECStatus rv; |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
199 | PRBool enabled; |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
200 | PRErrorCode err; |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
201 | SSLCipherSuiteInfo info; |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
202 | |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
203 | rv = SSL_CipherPrefGetDefault(suite, &enabled); |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
204 | if (rv != SECSuccess) { |
|
36219
703e982d8d18
Fix building with NSS 3.10.8 (which is what squeeze has and is probably the oldest we need to worry about)
Daniel Atallah <datallah@pidgin.im>
parents:
36209
diff
changeset
|
205 | gchar *error_txt = get_error_text(); |
|
36209
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
206 | purple_debug_warning("nss", |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
207 | "SSL_CipherPrefGetDefault didn't like value 0x%04x: %s\n", |
|
36219
703e982d8d18
Fix building with NSS 3.10.8 (which is what squeeze has and is probably the oldest we need to worry about)
Daniel Atallah <datallah@pidgin.im>
parents:
36209
diff
changeset
|
208 | suite, error_txt); |
|
703e982d8d18
Fix building with NSS 3.10.8 (which is what squeeze has and is probably the oldest we need to worry about)
Daniel Atallah <datallah@pidgin.im>
parents:
36209
diff
changeset
|
209 | g_free(error_txt); |
|
36209
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
210 | continue; |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
211 | } |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
212 | rv = SSL_GetCipherSuiteInfo(suite, &info, (int)(sizeof info)); |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
213 | if (rv != SECSuccess) { |
|
36219
703e982d8d18
Fix building with NSS 3.10.8 (which is what squeeze has and is probably the oldest we need to worry about)
Daniel Atallah <datallah@pidgin.im>
parents:
36209
diff
changeset
|
214 | gchar *error_txt = get_error_text(); |
|
36209
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
215 | purple_debug_warning("nss", |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
216 | "SSL_GetCipherSuiteInfo didn't like value 0x%04x: %s\n", |
|
36219
703e982d8d18
Fix building with NSS 3.10.8 (which is what squeeze has and is probably the oldest we need to worry about)
Daniel Atallah <datallah@pidgin.im>
parents:
36209
diff
changeset
|
217 | suite, error_txt); |
|
703e982d8d18
Fix building with NSS 3.10.8 (which is what squeeze has and is probably the oldest we need to worry about)
Daniel Atallah <datallah@pidgin.im>
parents:
36209
diff
changeset
|
218 | g_free(error_txt); |
|
36209
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
219 | continue; |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
220 | } |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
221 | purple_debug_info("nss", "Cipher - %s: %s\n", |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
222 | info.cipherSuiteName, |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
223 | enabled ? "Enabled" : "Disabled"); |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
224 | } |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
225 | } |
|
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
226 | |
|
7993
3bfea94dd0eb
[gaim-migrate @ 8670]
Christian Hammond <chipx86@chipx86.com>
parents:
7862
diff
changeset
|
227 | static void |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
228 | ssl_nss_init_nss(void) |
|
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
229 | { |
|
36164
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
230 | #if NSS_VMAJOR > 3 || ( NSS_VMAJOR == 3 && NSS_VMINOR >= 14 ) |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
231 | SSLVersionRange supported, enabled; |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
232 | #endif /* NSS >= 3.14 */ |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
233 | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
234 | PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); |
|
16866
2187f9250a16
Proabably fixes ticket #578, it's the recommended way of initializing NSS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16744
diff
changeset
|
235 | NSS_NoDB_Init("."); |
|
36219
703e982d8d18
Fix building with NSS 3.10.8 (which is what squeeze has and is probably the oldest we need to worry about)
Daniel Atallah <datallah@pidgin.im>
parents:
36209
diff
changeset
|
236 | #if (NSS_VMAJOR == 3 && (NSS_VMINOR < 15 || (NSS_VMINOR == 15 && NSS_VPATCH < 2))) |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
237 | NSS_SetDomesticPolicy(); |
|
36208
681554f27e84
As of NSS 3.15.2, NSS_SetDomesticPolicy() doesn't do anything, so don't use it.
Daniel Atallah <datallah@pidgin.im>
parents:
36207
diff
changeset
|
238 | #endif /* NSS < 3.15.2 */ |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
239 | |
|
36220
f26d96f03176
Update NSS Default Cipher suites
Daniel Atallah <datallah@pidgin.im>
parents:
36219
diff
changeset
|
240 | ssl_nss_init_ciphers(); |
|
24388
32a4cf358f9c
Enable a number of default-disabled strong ciphers for NSS.
Ethan Blanton <elb@pidgin.im>
parents:
24276
diff
changeset
|
241 | |
|
36164
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
242 | #if NSS_VMAJOR > 3 || ( NSS_VMAJOR == 3 && NSS_VMINOR >= 14 ) |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
243 | /* Get the ranges of supported and enabled SSL versions */ |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
244 | if ((SSL_VersionRangeGetSupported(ssl_variant_stream, &supported) == SECSuccess) && |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
245 | (SSL_VersionRangeGetDefault(ssl_variant_stream, &enabled) == SECSuccess)) { |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
246 | purple_debug_info("nss", "TLS supported versions: " |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
247 | "0x%04hx through 0x%04hx\n", supported.min, supported.max); |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
248 | purple_debug_info("nss", "TLS versions allowed by default: " |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
249 | "0x%04hx through 0x%04hx\n", enabled.min, enabled.max); |
|
36152
f4e63e354f45
Allow and prefer TLS 1.2 and 1.1 when using libnss. Patch from Elrond,
Mark Doliner <mark@kingant.net>
parents:
35623
diff
changeset
|
250 | |
|
36164
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
251 | /* Make sure all versions of TLS supported by the local library are |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
252 | enabled. (For some reason NSS doesn't enable newer versions of TLS |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
253 | by default -- more context in ticket #15909.) */ |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
254 | if (supported.max > enabled.max) { |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
255 | enabled.max = supported.max; |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
256 | if (SSL_VersionRangeSetDefault(ssl_variant_stream, &enabled) == SECSuccess) { |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
257 | purple_debug_info("nss", "Changed allowed TLS versions to " |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
258 | "0x%04hx through 0x%04hx\n", enabled.min, enabled.max); |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
259 | } else { |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
260 | purple_debug_error("nss", "Error setting allowed TLS versions to " |
|
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
261 | "0x%04hx through 0x%04hx\n", enabled.min, enabled.max); |
|
36152
f4e63e354f45
Allow and prefer TLS 1.2 and 1.1 when using libnss. Patch from Elrond,
Mark Doliner <mark@kingant.net>
parents:
35623
diff
changeset
|
262 | } |
|
f4e63e354f45
Allow and prefer TLS 1.2 and 1.1 when using libnss. Patch from Elrond,
Mark Doliner <mark@kingant.net>
parents:
35623
diff
changeset
|
263 | } |
|
f4e63e354f45
Allow and prefer TLS 1.2 and 1.1 when using libnss. Patch from Elrond,
Mark Doliner <mark@kingant.net>
parents:
35623
diff
changeset
|
264 | } |
|
36164
6d2325070ec8
Change this to a preprocessor check.
Mark Doliner <mark@kingant.net>
parents:
36162
diff
changeset
|
265 | #endif /* NSS >= 3.14 */ |
|
36152
f4e63e354f45
Allow and prefer TLS 1.2 and 1.1 when using libnss. Patch from Elrond,
Mark Doliner <mark@kingant.net>
parents:
35623
diff
changeset
|
266 | |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
267 | /** Disable OCSP Checking until we can make that use our HTTP & Proxy stuff */ |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
268 | CERT_EnableOCSPChecking(PR_FALSE); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
269 | |
| 15884 | 270 | _identity = PR_GetUniqueIdentity("Purple"); |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
271 | _nss_methods = PR_GetDefaultIOMethods(); |
|
36209
9bafa7dfb2a3
Add logging of supported and enabled cipher suites to the NSS plugin.
Daniel Atallah <datallah@pidgin.im>
parents:
36208
diff
changeset
|
272 | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
273 | } |
|
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
274 | |
| 7016 | 275 | static SECStatus |
|
35135
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
276 | ssl_auth_cert(void *arg, PRFileDesc *socket, PRBool checksig, PRBool is_server) |
| 7016 | 277 | { |
|
35135
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
278 | /* We just skip cert verification here, and will verify the whole chain |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
279 | * in ssl_nss_handshake_cb, after the handshake is complete. |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
280 | * |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
281 | * The problem is, purple_certificate_verify is asynchronous and |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
282 | * ssl_auth_cert should return the result synchronously (it may ask the |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
283 | * user, if an unknown certificate should be trusted or not). |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
284 | * |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
285 | * Ideally, SSL_AuthCertificateHook/ssl_auth_cert should decide |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
286 | * immediately, if the certificate chain is already trusted and possibly |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
287 | * SSL_BadCertHook to deal with unknown certificates. |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
288 | * |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
289 | * Current implementation may not be ideal, but is no less secure in |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
290 | * terms of MITM attack. |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
291 | */ |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
292 | return SECSuccess; |
| 7016 | 293 | } |
| 294 | ||
| 295 | static gboolean | |
| 296 | ssl_nss_init(void) | |
| 297 | { | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
298 | return TRUE; |
| 7016 | 299 | } |
| 300 | ||
| 301 | static void | |
| 302 | ssl_nss_uninit(void) | |
| 303 | { | |
|
29943
8bd0701c9bbd
nss: NSS should work after reiniting libpurple. Closes #11524.
Paul Aurich <darkrain42@pidgin.im>
parents:
29942
diff
changeset
|
304 | NSS_Shutdown(); |
| 7016 | 305 | PR_Cleanup(); |
| 306 | ||
| 307 | _nss_methods = NULL; | |
| 308 | } | |
| 309 | ||
| 310 | static void | |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
311 | ssl_nss_verified_cb(PurpleCertificateVerificationStatus st, |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
312 | gpointer userdata) |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
313 | { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
314 | PurpleSslConnection *gsc = (PurpleSslConnection *) userdata; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
315 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
316 | if (st == PURPLE_CERTIFICATE_VALID) { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
317 | /* Certificate valid? Good! Do the connection! */ |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
318 | gsc->connect_cb(gsc->connect_cb_data, gsc, PURPLE_INPUT_READ); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
319 | } else { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
320 | /* Otherwise, signal an error */ |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
321 | if(gsc->error_cb != NULL) |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
322 | gsc->error_cb(gsc, PURPLE_SSL_CERTIFICATE_INVALID, |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
323 | gsc->connect_cb_data); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
324 | purple_ssl_close(gsc); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
325 | } |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
326 | } |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
327 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
328 | /** Transforms an NSS containing an X.509 certificate into a Certificate instance |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
329 | * |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
330 | * @param cert Certificate to transform |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
331 | * @return A newly allocated Certificate |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
332 | */ |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
333 | static PurpleCertificate * |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
334 | x509_import_from_nss(CERTCertificate* cert) |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
335 | { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
336 | /* New certificate to return */ |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
337 | PurpleCertificate * crt; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
338 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
339 | /* Allocate the certificate and load it with data */ |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
340 | crt = g_new0(PurpleCertificate, 1); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
341 | crt->scheme = &x509_nss; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
342 | crt->data = CERT_DupCertificate(cert); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
343 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
344 | return crt; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
345 | } |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
346 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
347 | static GList * |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
348 | ssl_nss_get_peer_certificates(PRFileDesc *socket, PurpleSslConnection * gsc) |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
349 | { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
350 | CERTCertificate *curcert; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
351 | CERTCertificate *issuerCert; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
352 | PurpleCertificate * newcrt; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
353 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
354 | /* List of Certificate instances to return */ |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
355 | GList * peer_certs = NULL; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
356 | int count; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
357 | int64 now = PR_Now(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
358 | |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
359 | curcert = SSL_PeerCertificate(socket); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
360 | if (curcert == NULL) { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
361 | purple_debug_error("nss", "could not DupCertificate\n"); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
362 | return NULL; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
363 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
364 | |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
365 | for (count = 0 ; count < CERT_MAX_CERT_CHAIN ; count++) { |
|
24276
469eea3c328d
Fix a NULL pointer deref in the NSS SSL implementation with certain self-signed
Daniel Atallah <datallah@pidgin.im>
parents:
24065
diff
changeset
|
366 | purple_debug_info("nss", "subject=%s issuer=%s\n", curcert->subjectName, |
|
469eea3c328d
Fix a NULL pointer deref in the NSS SSL implementation with certain self-signed
Daniel Atallah <datallah@pidgin.im>
parents:
24065
diff
changeset
|
367 | curcert->issuerName ? curcert->issuerName : "(null)"); |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
368 | newcrt = x509_import_from_nss(curcert); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
369 | peer_certs = g_list_append(peer_certs, newcrt); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
370 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
371 | if (curcert->isRoot) { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
372 | break; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
373 | } |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
374 | issuerCert = CERT_FindCertIssuer(curcert, now, certUsageSSLServer); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
375 | if (!issuerCert) { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
376 | purple_debug_error("nss", "partial certificate chain\n"); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
377 | break; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
378 | } |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
379 | CERT_DestroyCertificate(curcert); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
380 | curcert = issuerCert; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
381 | } |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
382 | CERT_DestroyCertificate(curcert); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
383 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
384 | return peer_certs; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
385 | } |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
386 | |
|
35368
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
387 | /* |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
388 | * Ideally this information would be exposed to the UI somehow, but for now we |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
389 | * just print it to the debug log |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
390 | */ |
| 35623 | 391 | static void |
|
35622
b29a773d89c1
Avoid camel case function name.
Mark Doliner <mark@kingant.net>
parents:
35368
diff
changeset
|
392 | print_security_info(PRFileDesc *fd) |
|
35368
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
393 | { |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
394 | SECStatus result; |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
395 | SSLChannelInfo channel; |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
396 | SSLCipherSuiteInfo suite; |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
397 | |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
398 | result = SSL_GetChannelInfo(fd, &channel, sizeof channel); |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
399 | if (result == SECSuccess && channel.length == sizeof channel |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
400 | && channel.cipherSuite) { |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
401 | result = SSL_GetCipherSuiteInfo(channel.cipherSuite, |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
402 | &suite, sizeof suite); |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
403 | |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
404 | if (result == SECSuccess) { |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
405 | purple_debug_info("nss", "SSL version %d.%d using " |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
406 | "%d-bit %s with %d-bit %s MAC\n" |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
407 | "Server Auth: %d-bit %s, " |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
408 | "Key Exchange: %d-bit %s, " |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
409 | "Compression: %s\n" |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
410 | "Cipher Suite Name: %s\n", |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
411 | channel.protocolVersion >> 8, |
| 35623 | 412 | channel.protocolVersion & 0xff, |
|
35368
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
413 | suite.effectiveKeyBits, |
| 35623 | 414 | suite.symCipherName, |
|
35368
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
415 | suite.macBits, |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
416 | suite.macAlgorithmName, |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
417 | channel.authKeyBits, |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
418 | suite.authAlgorithmName, |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
419 | channel.keaKeyBits, suite.keaTypeName, |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
420 | channel.compressionMethodName, |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
421 | suite.cipherSuiteName); |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
422 | } |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
423 | } |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
424 | } |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
425 | |
|
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
426 | |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
427 | static void |
| 15884 | 428 | ssl_nss_handshake_cb(gpointer data, int fd, PurpleInputCondition cond) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
429 | { |
| 15884 | 430 | PurpleSslConnection *gsc = (PurpleSslConnection *)data; |
| 431 | PurpleSslNssData *nss_data = gsc->private_data; | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
432 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
433 | /* I don't think this the best way to do this... |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
434 | * It seems to work because it'll eventually use the cached value |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
435 | */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
436 | if(SSL_ForceHandshake(nss_data->in) != SECSuccess) { |
|
19847
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
437 | gchar *error_txt; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
438 | set_errno(PR_GetError()); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
439 | if (errno == EAGAIN || errno == EWOULDBLOCK) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
440 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
441 | |
|
19847
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
442 | error_txt = get_error_text(); |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
443 | purple_debug_error("nss", "Handshake failed %s (%d)\n", error_txt ? error_txt : "", PR_GetError()); |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
444 | g_free(error_txt); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
445 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
446 | if (gsc->error_cb != NULL) |
| 15884 | 447 | gsc->error_cb(gsc, PURPLE_SSL_HANDSHAKE_FAILED, gsc->connect_cb_data); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
448 | |
| 15884 | 449 | purple_ssl_close(gsc); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
450 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
451 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
452 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
453 | |
|
35622
b29a773d89c1
Avoid camel case function name.
Mark Doliner <mark@kingant.net>
parents:
35368
diff
changeset
|
454 | print_security_info(nss_data->in); |
|
35368
9728bb0f6dcc
Print information about the SSL connection to the debug log
Daniel Atallah <datallah@pidgin.im>
parents:
35135
diff
changeset
|
455 | |
| 15884 | 456 | purple_input_remove(nss_data->handshake_handler); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
457 | nss_data->handshake_handler = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
458 | |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
459 | /* If a Verifier was given, hand control over to it */ |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
460 | if (gsc->verifier) { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
461 | GList *peers; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
462 | /* First, get the peer cert chain */ |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
463 | peers = ssl_nss_get_peer_certificates(nss_data->in, gsc); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
464 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
465 | /* Now kick off the verification process */ |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
466 | purple_certificate_verify(gsc->verifier, |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
467 | gsc->host, |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
468 | peers, |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
469 | ssl_nss_verified_cb, |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
470 | gsc); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
471 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
472 | purple_certificate_destroy_list(peers); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
473 | } else { |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
474 | /* Otherwise, just call the "connection complete" |
|
35135
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
475 | * callback. The verification was already done with |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
476 | * SSL_AuthCertificate, the default verifier |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
477 | * (SSL_AuthCertificateHook was not called in ssl_nss_connect). |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
478 | */ |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
479 | gsc->connect_cb(gsc->connect_cb_data, gsc, cond); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
480 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
481 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
482 | |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
483 | static gboolean |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
484 | start_handshake_cb(gpointer data) |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
485 | { |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
486 | PurpleSslConnection *gsc = data; |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
487 | PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
488 | |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
489 | nss_data->handshake_timer = 0; |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
490 | |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
491 | ssl_nss_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ); |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
492 | return FALSE; |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
493 | } |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
494 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
495 | static void |
| 15884 | 496 | ssl_nss_connect(PurpleSslConnection *gsc) |
| 7016 | 497 | { |
| 15884 | 498 | PurpleSslNssData *nss_data = g_new0(PurpleSslNssData, 1); |
| 7016 | 499 | PRSocketOptionData socket_opt; |
| 500 | ||
| 501 | gsc->private_data = nss_data; | |
| 502 | ||
| 503 | nss_data->fd = PR_ImportTCPSocket(gsc->fd); | |
| 504 | ||
| 505 | if (nss_data->fd == NULL) | |
| 506 | { | |
| 15884 | 507 | purple_debug_error("nss", "nss_data->fd == NULL!\n"); |
| 7016 | 508 | |
| 8362 | 509 | if (gsc->error_cb != NULL) |
| 15884 | 510 | gsc->error_cb(gsc, PURPLE_SSL_CONNECT_FAILED, gsc->connect_cb_data); |
| 8362 | 511 | |
| 15884 | 512 | purple_ssl_close((PurpleSslConnection *)gsc); |
| 7016 | 513 | |
| 514 | return; | |
| 515 | } | |
| 516 | ||
| 517 | socket_opt.option = PR_SockOpt_Nonblocking; | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
518 | socket_opt.value.non_blocking = PR_TRUE; |
| 7016 | 519 | |
|
19847
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
520 | if (PR_SetSocketOption(nss_data->fd, &socket_opt) != PR_SUCCESS) { |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
521 | gchar *error_txt = get_error_text(); |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
522 | purple_debug_warning("nss", "unable to set socket into non-blocking mode: %s (%d)\n", error_txt ? error_txt : "", PR_GetError()); |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
523 | g_free(error_txt); |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
524 | } |
| 7016 | 525 | |
| 526 | nss_data->in = SSL_ImportFD(NULL, nss_data->fd); | |
| 527 | ||
| 528 | if (nss_data->in == NULL) | |
| 529 | { | |
| 15884 | 530 | purple_debug_error("nss", "nss_data->in == NUL!\n"); |
| 7016 | 531 | |
| 8362 | 532 | if (gsc->error_cb != NULL) |
| 15884 | 533 | gsc->error_cb(gsc, PURPLE_SSL_CONNECT_FAILED, gsc->connect_cb_data); |
| 8362 | 534 | |
| 15884 | 535 | purple_ssl_close((PurpleSslConnection *)gsc); |
| 7016 | 536 | |
| 537 | return; | |
| 538 | } | |
| 539 | ||
| 540 | SSL_OptionSet(nss_data->in, SSL_SECURITY, PR_TRUE); | |
| 541 | SSL_OptionSet(nss_data->in, SSL_HANDSHAKE_AS_CLIENT, PR_TRUE); | |
| 542 | ||
|
35135
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
543 | /* If we have our internal verifier set up, use it. Otherwise, |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
544 | * use default. */ |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
545 | if (gsc->verifier != NULL) |
|
72bdcc0f7267
Clean up unused ssl/NSS code and write up some comments to resolve any doubts. Refs #15308
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34242
diff
changeset
|
546 | SSL_AuthCertificateHook(nss_data->in, ssl_auth_cert, NULL); |
| 7016 | 547 | |
| 7157 | 548 | if(gsc->host) |
| 549 | SSL_SetURL(nss_data->in, gsc->host); | |
| 7016 | 550 | |
|
13264
f5db933aa42a
[gaim-migrate @ 15629]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13201
diff
changeset
|
551 | #if 0 |
|
f5db933aa42a
[gaim-migrate @ 15629]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13201
diff
changeset
|
552 | /* This seems like it'd the be the correct way to implement the |
|
f5db933aa42a
[gaim-migrate @ 15629]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13201
diff
changeset
|
553 | nonblocking stuff, but it doesn't seem to work */ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
554 | SSL_HandshakeCallback(nss_data->in, |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
555 | (SSLHandshakeCallback) ssl_nss_handshake_cb, gsc); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
556 | #endif |
| 7016 | 557 | SSL_ResetHandshake(nss_data->in, PR_FALSE); |
| 558 | ||
| 15884 | 559 | nss_data->handshake_handler = purple_input_add(gsc->fd, |
| 560 | PURPLE_INPUT_READ, ssl_nss_handshake_cb, gsc); | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7157
diff
changeset
|
561 | |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
562 | nss_data->handshake_timer = purple_timeout_add(0, start_handshake_cb, gsc); |
| 7016 | 563 | } |
| 564 | ||
| 565 | static void | |
| 15884 | 566 | ssl_nss_close(PurpleSslConnection *gsc) |
| 7016 | 567 | { |
| 15884 | 568 | PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); |
| 7016 | 569 | |
| 7467 | 570 | if(!nss_data) |
| 571 | return; | |
| 572 | ||
|
17623
4f45361d7e3b
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 <datallah@pidgin.im>
parents:
16866
diff
changeset
|
573 | if (nss_data->in) { |
|
4f45361d7e3b
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 <datallah@pidgin.im>
parents:
16866
diff
changeset
|
574 | PR_Close(nss_data->in); |
|
4f45361d7e3b
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 <datallah@pidgin.im>
parents:
16866
diff
changeset
|
575 | gsc->fd = -1; |
|
4f45361d7e3b
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 <datallah@pidgin.im>
parents:
16866
diff
changeset
|
576 | } else if (nss_data->fd) { |
|
4f45361d7e3b
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 <datallah@pidgin.im>
parents:
16866
diff
changeset
|
577 | PR_Close(nss_data->fd); |
|
4f45361d7e3b
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 <datallah@pidgin.im>
parents:
16866
diff
changeset
|
578 | gsc->fd = -1; |
|
4f45361d7e3b
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 <datallah@pidgin.im>
parents:
16866
diff
changeset
|
579 | } |
| 7016 | 580 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
581 | if (nss_data->handshake_handler) |
| 15884 | 582 | purple_input_remove(nss_data->handshake_handler); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
583 | |
|
29942
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
584 | if (nss_data->handshake_timer) |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
585 | purple_timeout_remove(nss_data->handshake_timer); |
|
4c74f05635c5
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
Paul Aurich <darkrain42@pidgin.im>
parents:
29930
diff
changeset
|
586 | |
| 7016 | 587 | g_free(nss_data); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
588 | gsc->private_data = NULL; |
| 7016 | 589 | } |
| 590 | ||
| 591 | static size_t | |
| 15884 | 592 | ssl_nss_read(PurpleSslConnection *gsc, void *data, size_t len) |
| 7016 | 593 | { |
|
33841
d91084abb15c
Fix return types for PR_Read/PR_Write.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33810
diff
changeset
|
594 | PRInt32 ret; |
| 15884 | 595 | PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); |
| 7016 | 596 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
597 | ret = PR_Read(nss_data->in, data, len); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
598 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
599 | if (ret == -1) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
600 | set_errno(PR_GetError()); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
601 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
602 | return ret; |
| 7016 | 603 | } |
| 604 | ||
| 605 | static size_t | |
| 15884 | 606 | ssl_nss_write(PurpleSslConnection *gsc, const void *data, size_t len) |
| 7016 | 607 | { |
|
33841
d91084abb15c
Fix return types for PR_Read/PR_Write.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33810
diff
changeset
|
608 | PRInt32 ret; |
| 15884 | 609 | PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); |
| 7016 | 610 | |
| 7467 | 611 | if(!nss_data) |
| 612 | return 0; | |
| 613 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
614 | ret = PR_Write(nss_data->in, data, len); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
615 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
616 | if (ret == -1) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
617 | set_errno(PR_GetError()); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
618 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12209
diff
changeset
|
619 | return ret; |
| 7016 | 620 | } |
| 621 | ||
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
622 | static GList * |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
623 | ssl_nss_peer_certs(PurpleSslConnection *gsc) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
624 | { |
|
20221
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
625 | #if 0 |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
626 | PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); |
|
19847
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
627 | CERTCertificate *cert; |
|
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
628 | /* |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
629 | GList *chain = NULL; |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
630 | void *pinArg; |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
631 | SECStatus status; |
|
19847
c53701927784
Attempt to display user readable error messages for NSS.
Daniel Atallah <datallah@pidgin.im>
parents:
19827
diff
changeset
|
632 | */ |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
633 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
634 | /* TODO: this is a blind guess */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
635 | cert = SSL_PeerCertificate(nss_data->fd); |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
636 | |
|
20221
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
637 | if (cert) |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
638 | CERT_DestroyCertificate(cert); |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
639 | #endif |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
640 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
641 | |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
642 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
643 | return NULL; |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
644 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
645 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
646 | /************************************************************************/ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
647 | /* X.509 functionality */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
648 | /************************************************************************/ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
649 | static PurpleCertificateScheme x509_nss; |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
650 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
651 | /** Helpr macro to retrieve the NSS certdata from a PurpleCertificate */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
652 | #define X509_NSS_DATA(pcrt) ( (CERTCertificate * ) (pcrt->data) ) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
653 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
654 | /** Imports a PEM-formatted X.509 certificate from the specified file. |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
655 | * @param filename Filename to import from. Format is PEM |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
656 | * |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
657 | * @return A newly allocated Certificate structure of the x509_nss scheme |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
658 | */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
659 | static PurpleCertificate * |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
660 | x509_import_from_file(const gchar *filename) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
661 | { |
|
19486
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
662 | gchar *rawcert; |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
663 | gsize len = 0; |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
664 | CERTCertificate *crt_dat; |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
665 | PurpleCertificate *crt; |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
666 | |
|
27823
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
667 | g_return_val_if_fail(filename != NULL, NULL); |
|
19486
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
668 | |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
669 | purple_debug_info("nss/x509", |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
670 | "Loading certificate from %s\n", |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
671 | filename); |
|
27823
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
672 | |
|
19486
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
673 | /* Load the raw data up */ |
|
20221
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
674 | if (!g_file_get_contents(filename, |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
675 | &rawcert, &len, |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
676 | NULL)) { |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
677 | purple_debug_error("nss/x509", "Unable to read certificate file.\n"); |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
678 | return NULL; |
|
28e31ee832cd
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
19984
diff
changeset
|
679 | } |
|
19486
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
680 | |
|
27823
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
681 | if (len == 0) { |
|
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
682 | purple_debug_error("nss/x509", |
|
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
683 | "Certificate file has no contents!\n"); |
|
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
684 | if (rawcert) |
|
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
685 | g_free(rawcert); |
|
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
686 | return NULL; |
|
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
687 | } |
|
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
688 | |
|
19486
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
689 | /* Decode the certificate */ |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
690 | crt_dat = CERT_DecodeCertFromPackage(rawcert, len); |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
691 | g_free(rawcert); |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
692 | |
|
27823
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
693 | g_return_val_if_fail(crt_dat != NULL, NULL); |
|
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27692
diff
changeset
|
694 | |
|
19486
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
695 | crt = g_new0(PurpleCertificate, 1); |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
696 | crt->scheme = &x509_nss; |
|
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
697 | crt->data = crt_dat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
698 | |
|
19486
83d0375f1784
- Add x509_import_from_file
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19485
diff
changeset
|
699 | return crt; |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
700 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
701 | |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
702 | /** Imports a number of PEM-formatted X.509 certificates from the specified file. |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
703 | * @param filename Filename to import from. Format is PEM |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
704 | * |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
705 | * @return A GSList of newly allocated Certificate structures of the x509_nss scheme |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
706 | */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
707 | static GSList * |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
708 | x509_importcerts_from_file(const gchar *filename) |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
709 | { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
710 | gchar *rawcert, *begin, *end; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
711 | gsize len = 0; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
712 | GSList *crts = NULL; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
713 | CERTCertificate *crt_dat; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
714 | PurpleCertificate *crt; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
715 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
716 | g_return_val_if_fail(filename != NULL, NULL); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
717 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
718 | purple_debug_info("nss/x509", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
719 | "Loading certificate from %s\n", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
720 | filename); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
721 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
722 | /* Load the raw data up */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
723 | if (!g_file_get_contents(filename, |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
724 | &rawcert, &len, |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
725 | NULL)) { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
726 | purple_debug_error("nss/x509", "Unable to read certificate file.\n"); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
727 | return NULL; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
728 | } |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
729 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
730 | if (len == 0) { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
731 | purple_debug_error("nss/x509", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
732 | "Certificate file has no contents!\n"); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
733 | if (rawcert) |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
734 | g_free(rawcert); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
735 | return NULL; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
736 | } |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
737 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
738 | begin = rawcert; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
739 | while((end = strstr(begin, "-----END CERTIFICATE-----")) != NULL) { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
740 | end += sizeof("-----END CERTIFICATE-----")-1; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
741 | /* Decode the certificate */ |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
742 | crt_dat = CERT_DecodeCertFromPackage(begin, (end-begin)); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
743 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
744 | g_return_val_if_fail(crt_dat != NULL, NULL); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
745 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
746 | crt = g_new0(PurpleCertificate, 1); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
747 | crt->scheme = &x509_nss; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
748 | crt->data = crt_dat; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
749 | crts = g_slist_prepend(crts, crt); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
750 | begin = end; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
751 | } |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
752 | g_free(rawcert); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
753 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
754 | return crts; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
755 | } |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
756 | /** |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
757 | * Exports a PEM-formatted X.509 certificate to the specified file. |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
758 | * @param filename Filename to export to. Format will be PEM |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
759 | * @param crt Certificate to export |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
760 | * |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
761 | * @return TRUE if success, otherwise FALSE |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
762 | */ |
|
19983
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
763 | /* This function should not be so complicated, but NSS doesn't seem to have a |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
764 | "convert yon certificate to PEM format" function. */ |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
765 | static gboolean |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
766 | x509_export_certificate(const gchar *filename, PurpleCertificate *crt) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
767 | { |
|
19983
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
768 | CERTCertificate *crt_dat; |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
769 | SECItem *dercrt; |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
770 | gchar *b64crt; |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
771 | gchar *pemcrt; |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
772 | gboolean ret = FALSE; |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
773 | |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
774 | g_return_val_if_fail(filename, FALSE); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
775 | g_return_val_if_fail(crt, FALSE); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
776 | g_return_val_if_fail(crt->scheme == &x509_nss, FALSE); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
777 | |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
778 | crt_dat = X509_NSS_DATA(crt); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
779 | g_return_val_if_fail(crt_dat, FALSE); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
780 | |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
781 | purple_debug_info("nss/x509", |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
782 | "Exporting certificate to %s\n", filename); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
783 | |
|
19983
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
784 | /* First, use NSS voodoo to create a DER-formatted certificate */ |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
785 | dercrt = SEC_ASN1EncodeItem(NULL, NULL, crt_dat, |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
786 | SEC_ASN1_GET(SEC_SignedCertificateTemplate)); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
787 | g_return_val_if_fail(dercrt != NULL, FALSE); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
788 | |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
789 | /* Now encode it to b64 */ |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
790 | b64crt = NSSBase64_EncodeItem(NULL, NULL, 0, dercrt); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
791 | SECITEM_FreeItem(dercrt, PR_TRUE); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
792 | g_return_val_if_fail(b64crt, FALSE); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
793 | |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
794 | /* Wrap it in nice PEM header things */ |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
795 | pemcrt = g_strdup_printf("-----BEGIN CERTIFICATE-----\n%s\n-----END CERTIFICATE-----\n", b64crt); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
796 | PORT_Free(b64crt); /* Notice that b64crt was allocated by an NSS |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
797 | function; hence, we'll let NSPR free it. */ |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
798 | |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
799 | /* Finally, dump the silly thing to a file. */ |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
800 | ret = purple_util_write_data_to_file_absolute(filename, pemcrt, -1); |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
801 | |
|
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
802 | g_free(pemcrt); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
803 | |
|
19983
2d79626570ae
- Make ssl-nss x509_export_certificate work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19982
diff
changeset
|
804 | return ret; |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
805 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
806 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
807 | static PurpleCertificate * |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
808 | x509_copy_certificate(PurpleCertificate *crt) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
809 | { |
|
19009
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
810 | CERTCertificate *crt_dat; |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
811 | PurpleCertificate *newcrt; |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
812 | |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
813 | g_return_val_if_fail(crt, NULL); |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
814 | g_return_val_if_fail(crt->scheme == &x509_nss, NULL); |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
815 | |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
816 | crt_dat = X509_NSS_DATA(crt); |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
817 | g_return_val_if_fail(crt_dat, NULL); |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
818 | |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
819 | /* Create the certificate copy */ |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
820 | newcrt = g_new0(PurpleCertificate, 1); |
|
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
821 | newcrt->scheme = &x509_nss; |
|
19023
547e94194c7a
- Comment on NSS's refcounting prowess
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
822 | /* NSS does refcounting automatically */ |
|
19009
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
823 | newcrt->data = CERT_DupCertificate(crt_dat); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
824 | |
|
19009
01fe9523e6d6
- x509_nss copy op
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
825 | return newcrt; |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
826 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
827 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
828 | /** Frees a Certificate |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
829 | * |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
830 | * Destroys a Certificate's internal data structures and frees the pointer |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
831 | * given. |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
832 | * @param crt Certificate instance to be destroyed. It WILL NOT be destroyed |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
833 | * if it is not of the correct CertificateScheme. Can be NULL |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
834 | * |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
835 | */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
836 | static void |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
837 | x509_destroy_certificate(PurpleCertificate * crt) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
838 | { |
|
19010
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
839 | CERTCertificate *crt_dat; |
|
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
840 | |
|
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
841 | g_return_if_fail(crt); |
|
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
842 | g_return_if_fail(crt->scheme == &x509_nss); |
|
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
843 | |
|
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
844 | crt_dat = X509_NSS_DATA(crt); |
|
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
845 | g_return_if_fail(crt_dat); |
|
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
846 | |
|
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
847 | /* Finally we have the certificate. So let's kill it */ |
|
19023
547e94194c7a
- Comment on NSS's refcounting prowess
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
848 | /* NSS does refcounting automatically */ |
|
19010
ad839d846fae
- x509_nss destroy_certificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
849 | CERT_DestroyCertificate(crt_dat); |
|
19027
921b7e331382
- x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
850 | |
|
921b7e331382
- x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
851 | /* Delete the PurpleCertificate as well */ |
|
921b7e331382
- x509_destroy_certificate is supposed to free the PurpleCertificate
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
852 | g_free(crt); |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
853 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
854 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
855 | /** Determines whether one certificate has been issued and signed by another |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
856 | * |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
857 | * @param crt Certificate to check the signature of |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
858 | * @param issuer Issuer's certificate |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
859 | * |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
860 | * @return TRUE if crt was signed and issued by issuer, otherwise FALSE |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
861 | * @TODO Modify this function to return a reason for invalidity? |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
862 | */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
863 | static gboolean |
|
19980
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
864 | x509_signed_by(PurpleCertificate * crt, |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
865 | PurpleCertificate * issuer) |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
866 | { |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
867 | CERTCertificate *subjectCert; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
868 | CERTCertificate *issuerCert; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
869 | SECStatus st; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
870 | |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
871 | issuerCert = X509_NSS_DATA(issuer); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
872 | g_return_val_if_fail(issuerCert, FALSE); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
873 | |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
874 | subjectCert = X509_NSS_DATA(crt); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
875 | g_return_val_if_fail(subjectCert, FALSE); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
876 | |
|
33810
8b2f9fad7227
ssl-nss: Fix handling of certificates without a Subject.
Daniel Atallah <datallah@pidgin.im>
parents:
33669
diff
changeset
|
877 | if (subjectCert->issuerName == NULL || issuerCert->subjectName == NULL |
|
24276
469eea3c328d
Fix a NULL pointer deref in the NSS SSL implementation with certain self-signed
Daniel Atallah <datallah@pidgin.im>
parents:
24065
diff
changeset
|
878 | || PORT_Strcmp(subjectCert->issuerName, issuerCert->subjectName) != 0) |
|
24065
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
879 | return FALSE; |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
880 | st = CERT_VerifySignedData(&subjectCert->signatureWrap, issuerCert, PR_Now(), NULL); |
|
bfc4c0035d91
Patch to fully enable NSS SSL Certificates from #6500.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
22104
diff
changeset
|
881 | return st == SECSuccess; |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
882 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
883 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
884 | static GByteArray * |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
885 | x509_sha1sum(PurpleCertificate *crt) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
886 | { |
|
19014
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
887 | CERTCertificate *crt_dat; |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
888 | size_t hashlen = 20; /* Size of an sha1sum */ |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
889 | GByteArray *sha1sum; |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
890 | SECItem *derCert; /* DER representation of the cert */ |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
891 | SECStatus st; |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
892 | |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
893 | g_return_val_if_fail(crt, NULL); |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
894 | g_return_val_if_fail(crt->scheme == &x509_nss, NULL); |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
895 | |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
896 | crt_dat = X509_NSS_DATA(crt); |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
897 | g_return_val_if_fail(crt_dat, NULL); |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
898 | |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
899 | /* Get the certificate DER representation */ |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
900 | derCert = &(crt_dat->derCert); |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
901 | |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
902 | /* Make a hash! */ |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
903 | sha1sum = g_byte_array_sized_new(hashlen); |
|
19797
92736e34b16a
- ssl-nss now reports a certificate's sha1sum correctly
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19671
diff
changeset
|
904 | /* glib leaves the size as 0 by default */ |
|
92736e34b16a
- ssl-nss now reports a certificate's sha1sum correctly
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19671
diff
changeset
|
905 | sha1sum->len = hashlen; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
906 | |
|
19014
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
907 | st = PK11_HashBuf(SEC_OID_SHA1, sha1sum->data, |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
908 | derCert->data, derCert->len); |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
909 | |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
910 | /* Check for errors */ |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
911 | if (st != SECSuccess) { |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
912 | g_byte_array_free(sha1sum, TRUE); |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
913 | purple_debug_error("nss/x509", |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
914 | "Error: hashing failed!\n"); |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
915 | return NULL; |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
916 | } |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
917 | |
|
1a67cc27fb12
- x509_nss sha1sum
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19013
diff
changeset
|
918 | return sha1sum; |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
919 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
920 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
921 | static gchar * |
|
19980
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
922 | x509_dn (PurpleCertificate *crt) |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
923 | { |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
924 | CERTCertificate *crt_dat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
925 | |
|
19980
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
926 | g_return_val_if_fail(crt, NULL); |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
927 | g_return_val_if_fail(crt->scheme == &x509_nss, NULL); |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
928 | |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
929 | crt_dat = X509_NSS_DATA(crt); |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
930 | g_return_val_if_fail(crt_dat, NULL); |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
931 | |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
932 | return g_strdup(crt_dat->subjectName); |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
933 | } |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
934 | |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
935 | static gchar * |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
936 | x509_issuer_dn (PurpleCertificate *crt) |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
937 | { |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
938 | CERTCertificate *crt_dat; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
939 | |
|
19980
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
940 | g_return_val_if_fail(crt, NULL); |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
941 | g_return_val_if_fail(crt->scheme == &x509_nss, NULL); |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
942 | |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
943 | crt_dat = X509_NSS_DATA(crt); |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
944 | g_return_val_if_fail(crt_dat, NULL); |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
945 | |
|
24577
fdb8b167200e
x509_issuer_dn() should return the certificate's issuer name, not the cert
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24513
diff
changeset
|
946 | return g_strdup(crt_dat->issuerName); |
|
19980
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
947 | } |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
948 | |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
949 | static gchar * |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
950 | x509_common_name (PurpleCertificate *crt) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
951 | { |
|
19011
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
952 | CERTCertificate *crt_dat; |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
953 | char *nss_cn; |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
954 | gchar *ret_cn; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
955 | |
|
19011
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
956 | g_return_val_if_fail(crt, NULL); |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
957 | g_return_val_if_fail(crt->scheme == &x509_nss, NULL); |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
958 | |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
959 | crt_dat = X509_NSS_DATA(crt); |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
960 | g_return_val_if_fail(crt_dat, NULL); |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
961 | |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
962 | /* Q: |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
963 | Why get a newly allocated string out of NSS, strdup it, and then |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
964 | return the new copy? |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
965 | |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
966 | A: |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
967 | The NSS LXR docs state that I should use the NSPR free functions on |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
968 | the strings that the NSS cert functions return. Since the libpurple |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
969 | API expects a g_free()-able string, we make our own copy and return |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
970 | that. |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
971 | |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
972 | NSPR is something of a prima donna. */ |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
973 | |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
974 | nss_cn = CERT_GetCommonName( &(crt_dat->subject) ); |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
975 | ret_cn = g_strdup(nss_cn); |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
976 | PORT_Free(nss_cn); |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
977 | |
|
21cdaee203e8
- x509_nss get_subject_name (x509_common_name)
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
978 | return ret_cn; |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
979 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
980 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
981 | static gboolean |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
982 | x509_check_name (PurpleCertificate *crt, const gchar *name) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
983 | { |
|
19012
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
984 | CERTCertificate *crt_dat; |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
985 | SECStatus st; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
986 | |
|
19012
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
987 | g_return_val_if_fail(crt, FALSE); |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
988 | g_return_val_if_fail(crt->scheme == &x509_nss, FALSE); |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
989 | |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
990 | crt_dat = X509_NSS_DATA(crt); |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
991 | g_return_val_if_fail(crt_dat, FALSE); |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
992 | |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
993 | st = CERT_VerifyCertName(crt_dat, name); |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
994 | |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
995 | if (st == SECSuccess) { |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
996 | return TRUE; |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
997 | } |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
998 | else if (st == SECFailure) { |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
999 | return FALSE; |
|
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
1000 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
1001 | |
|
19012
7813c38f34e9
- ssl-nss x509_nss check_name
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19011
diff
changeset
|
1002 | /* If we get here...bad things! */ |
|
19671
3848f6f679fd
- Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19486
diff
changeset
|
1003 | purple_debug_error("nss/x509", |
|
3848f6f679fd
- Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19486
diff
changeset
|
1004 | "x509_check_name fell through where it shouldn't " |
|
3848f6f679fd
- Change g_assert to purple_debug_error
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19486
diff
changeset
|
1005 | "have.\n"); |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1006 | return FALSE; |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1007 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1008 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1009 | static gboolean |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1010 | x509_times (PurpleCertificate *crt, time_t *activation, time_t *expiration) |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1011 | { |
|
19013
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1012 | CERTCertificate *crt_dat; |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1013 | PRTime nss_activ, nss_expir; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
1014 | |
|
19013
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1015 | g_return_val_if_fail(crt, FALSE); |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1016 | g_return_val_if_fail(crt->scheme == &x509_nss, FALSE); |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1017 | |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1018 | crt_dat = X509_NSS_DATA(crt); |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1019 | g_return_val_if_fail(crt_dat, FALSE); |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1020 | |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1021 | /* Extract the times into ugly PRTime thingies */ |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1022 | /* TODO: Maybe this shouldn't throw an error? */ |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1023 | g_return_val_if_fail( |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1024 | SECSuccess == CERT_GetCertTimes(crt_dat, |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1025 | &nss_activ, &nss_expir), |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1026 | FALSE); |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1027 | |
|
19982
1b453261f6ec
- Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19980
diff
changeset
|
1028 | /* NSS's native PRTime type *almost* corresponds to time_t; however, |
|
1b453261f6ec
- Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19980
diff
changeset
|
1029 | it measures *microseconds* since the epoch, not seconds. Hence |
|
1b453261f6ec
- Fix ssl-nss x509 to properly convert NSPR PRTime to time_t (in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19980
diff
changeset
|
1030 | the funny conversion. */ |
|
34242
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1031 | nss_activ = nss_activ / 1000000; |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1032 | nss_expir = nss_expir / 1000000; |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1033 | |
|
19013
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1034 | if (activation) { |
|
34242
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1035 | *activation = nss_activ; |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1036 | #if SIZEOF_TIME_T == 4 |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1037 | /** Hack to deal with dates past the 32-bit barrier. |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1038 | Handling is different for signed vs unsigned 32-bit types. |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1039 | */ |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1040 | if (*activation != nss_activ) { |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1041 | if (nss_activ < 0) { |
|
34242
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1042 | purple_debug_warning("nss", |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1043 | "Setting Activation Date to epoch to handle pre-epoch value\n"); |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1044 | *activation = 0; |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1045 | } else { |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1046 | purple_debug_error("nss", |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1047 | "Activation date past 32-bit barrier, forcing invalidity\n"); |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1048 | return FALSE; |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1049 | } |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1050 | } |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1051 | #endif |
|
19013
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1052 | } |
|
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1053 | if (expiration) { |
|
34242
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1054 | *expiration = nss_expir; |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1055 | #if SIZEOF_TIME_T == 4 |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1056 | if (*expiration != nss_expir) { |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1057 | if (*expiration < nss_expir) { |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1058 | if (*expiration < 0) { |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1059 | purple_debug_warning("nss", |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1060 | "Setting Expiration Date to 32-bit signed max\n"); |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1061 | *expiration = PR_INT32_MAX; |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1062 | } else { |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1063 | purple_debug_warning("nss", |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1064 | "Setting Expiration Date to 32-bit unsigned max\n"); |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1065 | *expiration = PR_UINT32_MAX; |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1066 | } |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1067 | } else { |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1068 | purple_debug_error("nss", |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1069 | "Expiration date prior to unix epoch, forcing invalidity\n"); |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1070 | return FALSE; |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1071 | } |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1072 | } |
|
2aa4d5ab8916
Add workaround so that certificates with times that can't be represented using
Daniel Atallah <datallah@pidgin.im>
parents:
33841
diff
changeset
|
1073 | #endif |
|
19013
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1074 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29943
diff
changeset
|
1075 | |
|
19013
60c74d9597f3
- x509_nss get_times
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19012
diff
changeset
|
1076 | return TRUE; |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1077 | } |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1078 | |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1079 | static gboolean |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1080 | x509_register_trusted_tls_cert(PurpleCertificate *crt, gboolean ca) |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1081 | { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1082 | CERTCertDBHandle *certdb = CERT_GetDefaultCertDB(); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1083 | CERTCertificate *crt_dat; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1084 | CERTCertTrust trust; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1085 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1086 | g_return_val_if_fail(crt, FALSE); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1087 | g_return_val_if_fail(crt->scheme == &x509_nss, FALSE); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1088 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1089 | crt_dat = X509_NSS_DATA(crt); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1090 | g_return_val_if_fail(crt_dat, FALSE); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1091 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1092 | purple_debug_info("nss", "Trusting %s\n", crt_dat->subjectName); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1093 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1094 | if (ca && !CERT_IsCACert(crt_dat, NULL)) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1095 | purple_debug_error("nss", |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1096 | "Refusing to set non-CA cert as trusted CA\n"); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1097 | return FALSE; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1098 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1099 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1100 | if (crt_dat->isperm) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1101 | purple_debug_info("nss", |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1102 | "Skipping setting trust for cert in permanent DB\n"); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1103 | return TRUE; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1104 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1105 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1106 | if (ca) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1107 | trust.sslFlags = CERTDB_TRUSTED_CA | CERTDB_TRUSTED_CLIENT_CA; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1108 | } else { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1109 | trust.sslFlags = CERTDB_TRUSTED; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1110 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1111 | trust.emailFlags = 0; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1112 | trust.objectSigningFlags = 0; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1113 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1114 | CERT_ChangeCertTrust(certdb, crt_dat, &trust); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1115 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1116 | return TRUE; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1117 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1118 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1119 | static void x509_verify_cert(PurpleCertificateVerificationRequest *vrq, PurpleCertificateInvalidityFlags *flags) |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1120 | { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1121 | CERTCertDBHandle *certdb = CERT_GetDefaultCertDB(); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1122 | CERTCertificate *crt_dat; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1123 | PRTime now = PR_Now(); |
|
36207
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1124 | SECStatus rv; |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1125 | PurpleCertificate *first_cert = vrq->cert_chain->data; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1126 | CERTVerifyLog log; |
|
36207
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1127 | gboolean self_signed = FALSE; |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1128 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1129 | crt_dat = X509_NSS_DATA(first_cert); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1130 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1131 | log.arena = PORT_NewArena(512); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1132 | log.head = log.tail = NULL; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1133 | log.count = 0; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1134 | rv = CERT_VerifyCert(certdb, crt_dat, PR_TRUE, certUsageSSLServer, now, NULL, &log); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1135 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1136 | if (rv != SECSuccess || log.count > 0) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1137 | CERTVerifyLogNode *node = NULL; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1138 | unsigned int depth = (unsigned int)-1; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1139 | |
|
36207
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1140 | if (crt_dat->isRoot) { |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1141 | self_signed = TRUE; |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1142 | *flags |= PURPLE_CERTIFICATE_SELF_SIGNED; |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1143 | } |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1144 | |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1145 | /* Handling of untrusted, etc. modeled after |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1146 | * source/security/manager/ssl/src/TransportSecurityInfo.cpp in Firefox |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1147 | */ |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1148 | for (node = log.head; node; node = node->next) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1149 | if (depth != node->depth) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1150 | depth = node->depth; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1151 | purple_debug_error("nss", "CERT %d. %s %s:\n", depth, |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1152 | node->cert->subjectName, |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1153 | depth ? "[Certificate Authority]": ""); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1154 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1155 | purple_debug_error("nss", " ERROR %ld: %s\n", node->error, |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1156 | PR_ErrorToName(node->error)); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1157 | switch (node->error) { |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1158 | case SEC_ERROR_EXPIRED_CERTIFICATE: |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1159 | *flags |= PURPLE_CERTIFICATE_EXPIRED; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1160 | break; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1161 | case SEC_ERROR_REVOKED_CERTIFICATE: |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1162 | *flags |= PURPLE_CERTIFICATE_REVOKED; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1163 | break; |
|
36204
9086eaeacd2c
Improve NSS handling for unknown CAs
Daniel Atallah <datallah@pidgin.im>
parents:
36191
diff
changeset
|
1164 | case SEC_ERROR_UNKNOWN_ISSUER: |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1165 | case SEC_ERROR_UNTRUSTED_ISSUER: |
|
36207
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1166 | if (!self_signed) { |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1167 | *flags |= PURPLE_CERTIFICATE_CA_UNKNOWN; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1168 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1169 | break; |
|
36207
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1170 | case SEC_ERROR_CA_CERT_INVALID: |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1171 | case SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE: |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1172 | case SEC_ERROR_UNTRUSTED_CERT: |
|
36219
703e982d8d18
Fix building with NSS 3.10.8 (which is what squeeze has and is probably the oldest we need to worry about)
Daniel Atallah <datallah@pidgin.im>
parents:
36209
diff
changeset
|
1173 | #ifdef SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1174 | case SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED: |
|
36219
703e982d8d18
Fix building with NSS 3.10.8 (which is what squeeze has and is probably the oldest we need to worry about)
Daniel Atallah <datallah@pidgin.im>
parents:
36209
diff
changeset
|
1175 | #endif |
|
36207
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1176 | if (!self_signed) { |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1177 | *flags |= PURPLE_CERTIFICATE_INVALID_CHAIN; |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1178 | } |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1179 | break; |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1180 | case SEC_ERROR_BAD_SIGNATURE: |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1181 | default: |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1182 | *flags |= PURPLE_CERTIFICATE_INVALID_CHAIN; |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1183 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1184 | if (node->cert) |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1185 | CERT_DestroyCertificate(node->cert); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1186 | } |
|
36207
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1187 | } |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1188 | |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1189 | rv = CERT_VerifyCertName(crt_dat, vrq->subject_name); |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1190 | if (rv != SECSuccess) { |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1191 | purple_debug_error("nss", "subject name not verified\n"); |
|
befb6523dc5c
Fix NSS handling of self-signed certificates. Fixes #16412.
Daniel Atallah <datallah@pidgin.im>
parents:
36204
diff
changeset
|
1192 | *flags |= PURPLE_CERTIFICATE_NAME_MISMATCH; |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1193 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1194 | |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1195 | PORT_FreeArena(log.arena, PR_FALSE); |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1196 | } |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1197 | |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1198 | static PurpleCertificateScheme x509_nss = { |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1199 | "x509", /* Scheme name */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1200 | N_("X.509 Certificates"), /* User-visible scheme name */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1201 | x509_import_from_file, /* Certificate import function */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1202 | x509_export_certificate, /* Certificate export function */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1203 | x509_copy_certificate, /* Copy */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1204 | x509_destroy_certificate, /* Destroy cert */ |
|
19980
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
1205 | x509_signed_by, /* Signed-by */ |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1206 | x509_sha1sum, /* SHA1 fingerprint */ |
|
19980
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
1207 | x509_dn, /* Unique ID */ |
|
35d5d780ba42
- Make ssl-nss unique_id and issuer_unique_id work
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19859
diff
changeset
|
1208 | x509_issuer_dn, /* Issuer Unique ID */ |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1209 | x509_common_name, /* Subject name */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1210 | x509_check_name, /* Check subject name */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19797
diff
changeset
|
1211 | x509_times, /* Activation/Expiration time */ |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
27935
diff
changeset
|
1212 | x509_importcerts_from_file, /* Multiple certificate import function */ |
|
36191
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1213 | x509_register_trusted_tls_cert, /* Register a certificate as trusted for TLS */ |
|
2e4475087f04
Fix basic constraints checking for both our SSL plugins.
Mark Doliner <mark@kingant.net>
parents:
36165
diff
changeset
|
1214 | x509_verify_cert, /* Verify that the specified cert chain is trusted */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19797
diff
changeset
|
1215 | NULL |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1216 | }; |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1217 | |
| 15884 | 1218 | static PurpleSslOps ssl_ops = |
| 7016 | 1219 | { |
| 1220 | ssl_nss_init, | |
| 1221 | ssl_nss_uninit, | |
|
14222
71d8761db708
[gaim-migrate @ 16808]
Mark Doliner <markdoliner@pidgin.im>
parents:
13530
diff
changeset
|
1222 | ssl_nss_connect, |
| 7016 | 1223 | ssl_nss_close, |
| 1224 | ssl_nss_read, | |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1225 | ssl_nss_write, |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1226 | ssl_nss_peer_certs, |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1227 | |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1228 | /* padding */ |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1229 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1230 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1231 | NULL |
| 7016 | 1232 | }; |
| 1233 | ||
| 1234 | ||
| 1235 | static gboolean | |
| 15884 | 1236 | plugin_load(PurplePlugin *plugin) |
| 7016 | 1237 | { |
| 15884 | 1238 | if (!purple_ssl_get_ops()) { |
| 1239 | purple_ssl_set_ops(&ssl_ops); | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
1240 | } |
| 7016 | 1241 | |
| 11033 | 1242 | /* Init NSS now, so others can use it even if sslconn never does */ |
| 1243 | ssl_nss_init_nss(); | |
| 1244 | ||
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1245 | /* Register the X.509 functions we provide */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1246 | purple_certificate_register_scheme(&x509_nss); |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1247 | |
| 7016 | 1248 | return TRUE; |
| 1249 | } | |
| 1250 | ||
| 1251 | static gboolean | |
| 15884 | 1252 | plugin_unload(PurplePlugin *plugin) |
| 7016 | 1253 | { |
| 15884 | 1254 | if (purple_ssl_get_ops() == &ssl_ops) { |
| 1255 | purple_ssl_set_ops(NULL); | |
|
7862
9b96706e44e7
[gaim-migrate @ 8516]
Bill Tompkins <obobo@users.sourceforge.net>
parents:
7467
diff
changeset
|
1256 | } |
|
19008
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1257 | |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1258 | /* Unregister our X.509 functions */ |
|
222e4861b5a2
- Skeleton for ssl-nss x509 provider
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17673
diff
changeset
|
1259 | purple_certificate_unregister_scheme(&x509_nss); |
|
7050
12730863b0f9
[gaim-migrate @ 7613]
Christian Hammond <chipx86@chipx86.com>
parents:
7029
diff
changeset
|
1260 | |
| 7016 | 1261 | return TRUE; |
| 1262 | } | |
| 1263 | ||
| 15884 | 1264 | static PurplePluginInfo info = |
| 7016 | 1265 | { |
| 15884 | 1266 | PURPLE_PLUGIN_MAGIC, |
| 1267 | PURPLE_MAJOR_VERSION, | |
| 1268 | PURPLE_MINOR_VERSION, | |
| 1269 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
| 7016 | 1270 | NULL, /**< ui_requirement */ |
| 15884 | 1271 | PURPLE_PLUGIN_FLAG_INVISIBLE, /**< flags */ |
| 7016 | 1272 | NULL, /**< dependencies */ |
| 15884 | 1273 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 7016 | 1274 | |
|
7029
fe690e0607ec
[gaim-migrate @ 7592]
Christian Hammond <chipx86@chipx86.com>
parents:
7028
diff
changeset
|
1275 | SSL_NSS_PLUGIN_ID, /**< id */ |
| 7016 | 1276 | N_("NSS"), /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20221
diff
changeset
|
1277 | DISPLAY_VERSION, /**< version */ |
| 7016 | 1278 | /** summary */ |
| 1279 | N_("Provides SSL support through Mozilla NSS."), | |
| 1280 | /** description */ | |
| 1281 | N_("Provides SSL support through Mozilla NSS."), | |
| 1282 | "Christian Hammond <chipx86@gnupdate.org>", | |
| 15884 | 1283 | PURPLE_WEBSITE, /**< homepage */ |
| 7016 | 1284 | |
| 1285 | plugin_load, /**< load */ | |
| 1286 | plugin_unload, /**< unload */ | |
| 1287 | NULL, /**< destroy */ | |
| 1288 | ||
| 1289 | NULL, /**< ui_info */ | |
|
11513
89bf8d856291
[gaim-migrate @ 13758]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11256
diff
changeset
|
1290 | NULL, /**< extra_info */ |
|
89bf8d856291
[gaim-migrate @ 13758]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11256
diff
changeset
|
1291 | NULL, /**< prefs_info */ |
|
16744
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1292 | NULL, /**< actions */ |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1293 | |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1294 | /* padding */ |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1295 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1296 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1297 | NULL, |
|
fcdab37ba1c2
Added NULL pads to ssl stuff
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
1298 | NULL |
| 7016 | 1299 | }; |
| 1300 | ||
| 1301 | static void | |
| 15884 | 1302 | init_plugin(PurplePlugin *plugin) |
| 7016 | 1303 | { |
| 1304 | } | |
| 1305 | ||
| 15884 | 1306 | PURPLE_INIT_PLUGIN(ssl_nss, init_plugin, info) |