Mercurial > pidgin.yaz
annotate libpurple/certificate.c @ 21553:5cd93ff08ecc
Don't crash when connecting to jabber.freenet.de. Michael Weitzel sent
an email about this to the Pidgin devel mailing list on 21 October
2007. I would appreciate if someone familiar with the certificate code
could check this change.
Also, should we prompt the user if they want to continue trying to
connect in the case where the certificate chain is invalid?
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 16 Nov 2007 07:49:55 +0000 |
parents | a20ef7180680 |
children | 7109257d4612 |
rev | line source |
---|---|
17638
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1 /** |
19075 | 2 * @file certificate.c Public-Key Certificate API |
17638
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
3 * @ingroup core |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
4 */ |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
5 |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
6 /* |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
7 * |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
8 * purple |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
9 * |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
10 * Purple is the legal property of its developers, whose names are too numerous |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
11 * to list here. Please refer to the COPYRIGHT file distributed with this |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
12 * source distribution. |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
13 * |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
14 * This program is free software; you can redistribute it and/or modify |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
15 * it under the terms of the GNU General Public License as published by |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
16 * the Free Software Foundation; either version 2 of the License, or |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
17 * (at your option) any later version. |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
18 * |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
19 * This program is distributed in the hope that it will be useful, |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
22 * GNU General Public License for more details. |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
23 * |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
24 * You should have received a copy of the GNU General Public License |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
25 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19648
diff
changeset
|
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
17638
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
27 */ |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
28 |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
29 #include <glib.h> |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
30 |
19504
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
31 #include "internal.h" |
17638
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
32 #include "certificate.h" |
19517
7bea9c9fd2a5
(Un)Register the pools with DBus to avoid a runtime fit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19515
diff
changeset
|
33 #include "dbus-maybe.h" |
18192
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
34 #include "debug.h" |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
35 #include "request.h" |
19044
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
36 #include "signals.h" |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
37 #include "util.h" |
17638
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
38 |
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
39 /** List holding pointers to all registered certificate schemes */ |
18192
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
40 static GList *cert_schemes = NULL; |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
41 /** List of registered Verifiers */ |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
42 static GList *cert_verifiers = NULL; |
18971
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
43 /** List of registered Pools */ |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
44 static GList *cert_pools = NULL; |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
45 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
46 void |
18942
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
47 purple_certificate_verify (PurpleCertificateVerifier *verifier, |
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
48 const gchar *subject_name, GList *cert_chain, |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
49 PurpleCertificateVerifiedCallback cb, |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
50 gpointer cb_data) |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
51 { |
18942
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
52 PurpleCertificateVerificationRequest *vrq; |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
53 PurpleCertificateScheme *scheme; |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
54 |
18942
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
55 g_return_if_fail(subject_name != NULL); |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
56 /* If you don't have a cert to check, why are you requesting that it |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
57 be verified? */ |
18942
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
58 g_return_if_fail(cert_chain != NULL); |
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
59 g_return_if_fail(cb != NULL); |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
60 |
18942
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
61 /* Look up the CertificateScheme */ |
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
62 scheme = purple_certificate_find_scheme(verifier->scheme_name); |
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
63 g_return_if_fail(scheme); |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
64 |
18943
c519ff185569
- purple_certificate_verify attempts to check that the cert chain is of
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18942
diff
changeset
|
65 /* Check that at least the first cert in the chain matches the |
c519ff185569
- purple_certificate_verify attempts to check that the cert chain is of
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18942
diff
changeset
|
66 Verifier scheme */ |
18960
6831c126bcf3
- Fixed an inverted assertion
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18957
diff
changeset
|
67 g_return_if_fail(scheme == |
18943
c519ff185569
- purple_certificate_verify attempts to check that the cert chain is of
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18942
diff
changeset
|
68 ((PurpleCertificate *) (cert_chain->data))->scheme); |
c519ff185569
- purple_certificate_verify attempts to check that the cert chain is of
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18942
diff
changeset
|
69 |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
70 /* Construct and fill in the request fields */ |
18949
8902f0d7e40f
- Use g_new0 instead of g_new
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18947
diff
changeset
|
71 vrq = g_new0(PurpleCertificateVerificationRequest, 1); |
18942
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
72 vrq->verifier = verifier; |
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
73 vrq->scheme = scheme; |
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
74 vrq->subject_name = g_strdup(subject_name); |
19021
fcca10d0ac7d
- purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
75 vrq->cert_chain = purple_certificate_copy_list(cert_chain); |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
76 vrq->cb = cb; |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
77 vrq->cb_data = cb_data; |
18942
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
78 |
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
79 /* Initiate verification */ |
02102eccc4be
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18941
diff
changeset
|
80 (verifier->start_verification)(vrq); |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
81 } |
18192
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
82 |
18946
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
83 void |
19088
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
84 purple_certificate_verify_complete(PurpleCertificateVerificationRequest *vrq, |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
85 PurpleCertificateVerificationStatus st) |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
86 { |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
87 PurpleCertificateVerifier *vr; |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
88 |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
89 g_return_if_fail(vrq); |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
90 |
20747
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
91 if (st == PURPLE_CERTIFICATE_VALID) { |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
92 purple_debug_info("certificate", |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
93 "Successfully verified certificate for %s\n", |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
94 vrq->subject_name); |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
95 } else { |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
96 purple_debug_info("certificate", |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
97 "Failed to verify certificate for %s\n", |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
98 vrq->subject_name); |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
99 } |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
100 |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
101 |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
102 |
17e605dd2de1
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20746
diff
changeset
|
103 |
19088
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
104 /* Pass the results on to the request's callback */ |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
105 (vrq->cb)(st, vrq->cb_data); |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
106 |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
107 /* And now to eliminate the request */ |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
108 /* Fetch the Verifier responsible... */ |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
109 vr = vrq->verifier; |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
110 /* ...and order it to KILL */ |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
111 (vr->destroy_request)(vrq); |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
112 |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
113 /* Now the internals have been cleaned up, so clean up the libpurple- |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
114 created elements */ |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
115 g_free(vrq->subject_name); |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
116 purple_certificate_destroy_list(vrq->cert_chain); |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
117 |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
118 /* A structure born |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
119 * to much ado |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
120 * and with so much within. |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
121 * It reaches now |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
122 * its quiet end. */ |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
123 g_free(vrq); |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
124 } |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
125 |
f5802217844d
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19086
diff
changeset
|
126 |
19018
d6f902265076
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
127 PurpleCertificate * |
d6f902265076
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
128 purple_certificate_copy(PurpleCertificate *crt) |
d6f902265076
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
129 { |
d6f902265076
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
130 g_return_val_if_fail(crt, NULL); |
d6f902265076
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
131 g_return_val_if_fail(crt->scheme, NULL); |
d6f902265076
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
132 g_return_val_if_fail(crt->scheme->copy_certificate, NULL); |
d6f902265076
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
133 |
d6f902265076
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
134 return (crt->scheme->copy_certificate)(crt); |
d6f902265076
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19014
diff
changeset
|
135 } |
18947
3c6bf77bf7c4
- Add purple_certificate_verify_destroy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18946
diff
changeset
|
136 |
19020
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
137 GList * |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
138 purple_certificate_copy_list(GList *crt_list) |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
139 { |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
140 GList *new, *l; |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
141 |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
142 /* First, make a shallow copy of the list */ |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
143 new = g_list_copy(crt_list); |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
144 |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
145 /* Now go through and actually duplicate each certificate */ |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
146 for (l = new; l; l = l->next) { |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
147 l->data = purple_certificate_copy(l->data); |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
148 } |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
149 |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
150 return new; |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
151 } |
d69355001a6e
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
152 |
18947
3c6bf77bf7c4
- Add purple_certificate_verify_destroy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18946
diff
changeset
|
153 void |
18946
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
154 purple_certificate_destroy (PurpleCertificate *crt) |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
155 { |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
156 PurpleCertificateScheme *scheme; |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
157 |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
158 if (NULL == crt) return; |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
159 |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
160 scheme = crt->scheme; |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
161 |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
162 (scheme->destroy_certificate)(crt); |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
163 } |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
164 |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
165 void |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
166 purple_certificate_destroy_list (GList * crt_list) |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
167 { |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
168 PurpleCertificate *crt; |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
169 GList *l; |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
170 |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
171 for (l=crt_list; l; l = l->next) { |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
172 crt = (PurpleCertificate *) l->data; |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
173 purple_certificate_destroy(crt); |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
174 } |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
175 |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
176 g_list_free(crt_list); |
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
177 } |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
178 |
19076
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
179 gboolean |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
180 purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer) |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
181 { |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
182 PurpleCertificateScheme *scheme; |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
183 |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
184 g_return_val_if_fail(crt, FALSE); |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
185 g_return_val_if_fail(issuer, FALSE); |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
186 |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
187 scheme = crt->scheme; |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
188 g_return_val_if_fail(scheme, FALSE); |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
189 /* We can't compare two certs of unrelated schemes, obviously */ |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
190 g_return_val_if_fail(issuer->scheme == scheme, FALSE); |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
191 |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
192 return (scheme->signed_by)(crt, issuer); |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
193 } |
daa68185a018
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19075
diff
changeset
|
194 |
19077
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
195 gboolean |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
196 purple_certificate_check_signature_chain(GList *chain) |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
197 { |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
198 GList *cur; |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
199 PurpleCertificate *crt, *issuer; |
19081
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
200 gchar *uid; |
19077
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
201 |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
202 g_return_val_if_fail(chain, FALSE); |
19081
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
203 |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
204 uid = purple_certificate_get_unique_id((PurpleCertificate *) chain->data); |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
205 purple_debug_info("certificate", |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
206 "Checking signature chain for uid=%s\n", |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
207 uid); |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
208 g_free(uid); |
19077
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
209 |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
210 /* If this is a single-certificate chain, say that it is valid */ |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
211 if (chain->next == NULL) { |
19081
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
212 purple_debug_info("certificate", |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
213 "...Singleton. We'll say it's valid.\n"); |
19077
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
214 return TRUE; |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
215 } |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
216 |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
217 /* Load crt with the first certificate */ |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
218 crt = (PurpleCertificate *)(chain->data); |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
219 /* And start with the second certificate in the chain */ |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
220 for ( cur = chain->next; cur; cur = cur->next ) { |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
221 |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
222 issuer = (PurpleCertificate *)(cur->data); |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
223 |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
224 /* Check the signature for this link */ |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
225 if (! purple_certificate_signed_by(crt, issuer) ) { |
19081
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
226 uid = purple_certificate_get_unique_id(issuer); |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
227 purple_debug_info("certificate", |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
228 "...Bad or missing signature by %s\nChain is INVALID\n", |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
229 uid); |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
230 g_free(uid); |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
231 |
19077
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
232 return FALSE; |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
233 } |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
234 |
19081
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
235 uid = purple_certificate_get_unique_id(issuer); |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
236 purple_debug_info("certificate", |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
237 "...Good signature by %s\n", |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
238 uid); |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
239 g_free(uid); |
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
240 |
19077
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
241 /* The issuer is now the next crt whose signature is to be |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
242 checked */ |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
243 crt = issuer; |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
244 } |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
245 |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
246 /* If control reaches this point, the chain is valid */ |
19081
bdd8911d5031
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19080
diff
changeset
|
247 purple_debug_info("certificate", "Chain is VALID\n"); |
19077
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
248 return TRUE; |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
249 } |
8275c3cbc9da
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19076
diff
changeset
|
250 |
18988
4189fc3befba
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18987
diff
changeset
|
251 PurpleCertificate * |
18989
43d1ee6a3ed5
- Fixed naming issues in previous revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18988
diff
changeset
|
252 purple_certificate_import(PurpleCertificateScheme *scheme, const gchar *filename) |
18988
4189fc3befba
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18987
diff
changeset
|
253 { |
4189fc3befba
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18987
diff
changeset
|
254 g_return_val_if_fail(scheme, NULL); |
4189fc3befba
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18987
diff
changeset
|
255 g_return_val_if_fail(scheme->import_certificate, NULL); |
4189fc3befba
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18987
diff
changeset
|
256 g_return_val_if_fail(filename, NULL); |
4189fc3befba
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18987
diff
changeset
|
257 |
4189fc3befba
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18987
diff
changeset
|
258 return (scheme->import_certificate)(filename); |
4189fc3befba
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18987
diff
changeset
|
259 } |
4189fc3befba
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18987
diff
changeset
|
260 |
18977
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
261 gboolean |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
262 purple_certificate_export(const gchar *filename, PurpleCertificate *crt) |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
263 { |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
264 PurpleCertificateScheme *scheme; |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
265 |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
266 g_return_val_if_fail(filename, FALSE); |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
267 g_return_val_if_fail(crt, FALSE); |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
268 g_return_val_if_fail(crt->scheme, FALSE); |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
269 |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
270 scheme = crt->scheme; |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
271 g_return_val_if_fail(scheme->export_certificate, FALSE); |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
272 |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
273 return (scheme->export_certificate)(filename, crt); |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
274 } |
31bdbb82de7e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18976
diff
changeset
|
275 |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
276 GByteArray * |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
277 purple_certificate_get_fingerprint_sha1(PurpleCertificate *crt) |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
278 { |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
279 PurpleCertificateScheme *scheme; |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
280 GByteArray *fpr; |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
281 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
282 g_return_val_if_fail(crt, NULL); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
283 g_return_val_if_fail(crt->scheme, NULL); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
284 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
285 scheme = crt->scheme; |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
286 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
287 g_return_val_if_fail(scheme->get_fingerprint_sha1, NULL); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
288 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
289 fpr = (scheme->get_fingerprint_sha1)(crt); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
290 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
291 return fpr; |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
292 } |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
293 |
18962
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
294 gchar * |
19080
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
295 purple_certificate_get_unique_id(PurpleCertificate *crt) |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
296 { |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
297 g_return_val_if_fail(crt, NULL); |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
298 g_return_val_if_fail(crt->scheme, NULL); |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
299 g_return_val_if_fail(crt->scheme->get_unique_id, NULL); |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
300 |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
301 return (crt->scheme->get_unique_id)(crt); |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
302 } |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
303 |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
304 gchar * |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
305 purple_certificate_get_issuer_unique_id(PurpleCertificate *crt) |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
306 { |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
307 g_return_val_if_fail(crt, NULL); |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
308 g_return_val_if_fail(crt->scheme, NULL); |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
309 g_return_val_if_fail(crt->scheme->get_issuer_unique_id, NULL); |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
310 |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
311 return (crt->scheme->get_issuer_unique_id)(crt); |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
312 } |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
313 |
3bdede51c007
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19078
diff
changeset
|
314 gchar * |
18962
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
315 purple_certificate_get_subject_name(PurpleCertificate *crt) |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
316 { |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
317 PurpleCertificateScheme *scheme; |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
318 gchar *subject_name; |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
319 |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
320 g_return_val_if_fail(crt, NULL); |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
321 g_return_val_if_fail(crt->scheme, NULL); |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
322 |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
323 scheme = crt->scheme; |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
324 |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
325 g_return_val_if_fail(scheme->get_subject_name, NULL); |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
326 |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
327 subject_name = (scheme->get_subject_name)(crt); |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
328 |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
329 return subject_name; |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
330 } |
fcd05c39803e
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18960
diff
changeset
|
331 |
19008
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
332 gboolean |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
333 purple_certificate_check_subject_name(PurpleCertificate *crt, const gchar *name) |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
334 { |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
335 PurpleCertificateScheme *scheme; |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
336 |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
337 g_return_val_if_fail(crt, FALSE); |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
338 g_return_val_if_fail(crt->scheme, FALSE); |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
339 g_return_val_if_fail(name, FALSE); |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
340 |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
341 scheme = crt->scheme; |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
342 |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
343 /* TODO: Instead of failing, maybe use get_subject_name and strcmp? */ |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
344 g_return_val_if_fail(scheme->check_subject_name, FALSE); |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
345 |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
346 return (scheme->check_subject_name)(crt, name); |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
347 } |
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
348 |
19012
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
349 gboolean |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
350 purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t *expiration) |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
351 { |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
352 PurpleCertificateScheme *scheme; |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
353 |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
354 g_return_val_if_fail(crt, FALSE); |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
355 |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
356 scheme = crt->scheme; |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
357 |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
358 g_return_val_if_fail(scheme, FALSE); |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
359 |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
360 /* If both provided references are NULL, what are you doing calling |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
361 this? */ |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
362 g_return_val_if_fail( (activation != NULL) || (expiration != NULL), FALSE); |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
363 |
19067
6c0aad79c4c5
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19063
diff
changeset
|
364 /* Throw the request on down to the certscheme */ |
6c0aad79c4c5
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19063
diff
changeset
|
365 return (scheme->get_times)(crt, activation, expiration); |
19012
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
366 } |
b1090cbfc286
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19010
diff
changeset
|
367 |
19008
7fd9bd55f8d0
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19001
diff
changeset
|
368 |
18984
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
369 gchar * |
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
370 purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id) |
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
371 { |
19010
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
372 gchar *path; |
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
373 gchar *esc_scheme_name, *esc_name, *esc_id; |
18984
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
374 |
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
375 g_return_val_if_fail(pool, NULL); |
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
376 g_return_val_if_fail(pool->scheme_name, NULL); |
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
377 g_return_val_if_fail(pool->name, NULL); |
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
378 |
19010
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
379 /* Escape all the elements for filesystem-friendliness */ |
19033
6b4e874e47c1
- Handle NULLs given to certificate_pool_mkpath without causing errors
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19027
diff
changeset
|
380 esc_scheme_name = pool ? g_strdup(purple_escape_filename(pool->scheme_name)) : NULL; |
6b4e874e47c1
- Handle NULLs given to certificate_pool_mkpath without causing errors
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19027
diff
changeset
|
381 esc_name = pool ? g_strdup(purple_escape_filename(pool->name)) : NULL; |
6b4e874e47c1
- Handle NULLs given to certificate_pool_mkpath without causing errors
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19027
diff
changeset
|
382 esc_id = id ? g_strdup(purple_escape_filename(id)) : NULL; |
19010
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
383 |
18984
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
384 path = g_build_filename(purple_user_dir(), |
18986
dfd9f883b774
- Correct the certstore folder paths
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18985
diff
changeset
|
385 "certificates", /* TODO: constantize this? */ |
19010
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
386 esc_scheme_name, |
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
387 esc_name, |
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
388 esc_id, |
18984
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
389 NULL); |
19009
b64aa0222a7a
- pool_mkpath now runs purple_escape_filename on its return value
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19008
diff
changeset
|
390 |
19010
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
391 g_free(esc_scheme_name); |
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
392 g_free(esc_name); |
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
393 g_free(esc_id); |
0d4b84820390
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19009
diff
changeset
|
394 return path; |
18984
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
395 } |
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
396 |
18995
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
397 gboolean |
19034
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
398 purple_certificate_pool_usable(PurpleCertificatePool *pool) |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
399 { |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
400 g_return_val_if_fail(pool, FALSE); |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
401 g_return_val_if_fail(pool->scheme_name, FALSE); |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
402 |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
403 /* Check that the pool's scheme is loaded */ |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
404 if (purple_certificate_find_scheme(pool->scheme_name) == NULL) { |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
405 return FALSE; |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
406 } |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
407 |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
408 return TRUE; |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
409 } |
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
410 |
19060
c79b54f03f9d
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19050
diff
changeset
|
411 PurpleCertificateScheme * |
c79b54f03f9d
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19050
diff
changeset
|
412 purple_certificate_pool_get_scheme(PurpleCertificatePool *pool) |
c79b54f03f9d
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19050
diff
changeset
|
413 { |
c79b54f03f9d
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19050
diff
changeset
|
414 g_return_val_if_fail(pool, NULL); |
c79b54f03f9d
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19050
diff
changeset
|
415 g_return_val_if_fail(pool->scheme_name, NULL); |
c79b54f03f9d
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19050
diff
changeset
|
416 |
c79b54f03f9d
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19050
diff
changeset
|
417 return purple_certificate_find_scheme(pool->scheme_name); |
c79b54f03f9d
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19050
diff
changeset
|
418 } |
c79b54f03f9d
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19050
diff
changeset
|
419 |
19034
8b627694bf4a
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
420 gboolean |
18995
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
421 purple_certificate_pool_contains(PurpleCertificatePool *pool, const gchar *id) |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
422 { |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
423 g_return_val_if_fail(pool, FALSE); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
424 g_return_val_if_fail(id, FALSE); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
425 g_return_val_if_fail(pool->cert_in_pool, FALSE); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
426 |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
427 return (pool->cert_in_pool)(id); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
428 } |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
429 |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
430 PurpleCertificate * |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
431 purple_certificate_pool_retrieve(PurpleCertificatePool *pool, const gchar *id) |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
432 { |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
433 g_return_val_if_fail(pool, NULL); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
434 g_return_val_if_fail(id, NULL); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
435 g_return_val_if_fail(pool->get_cert, NULL); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
436 |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
437 return (pool->get_cert)(id); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
438 } |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
439 |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
440 gboolean |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
441 purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, PurpleCertificate *crt) |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
442 { |
19046
8599a27ad69c
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19044
diff
changeset
|
443 gboolean ret = FALSE; |
8599a27ad69c
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19044
diff
changeset
|
444 |
18995
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
445 g_return_val_if_fail(pool, FALSE); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
446 g_return_val_if_fail(id, FALSE); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
447 g_return_val_if_fail(pool->put_cert, FALSE); |
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
448 |
18996
24fc5ca67afc
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18995
diff
changeset
|
449 /* Whether crt->scheme matches find_scheme(pool->scheme_name) is not |
24fc5ca67afc
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18995
diff
changeset
|
450 relevant... I think... */ |
24fc5ca67afc
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18995
diff
changeset
|
451 g_return_val_if_fail( |
24fc5ca67afc
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18995
diff
changeset
|
452 g_ascii_strcasecmp(pool->scheme_name, crt->scheme->name) == 0, |
24fc5ca67afc
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18995
diff
changeset
|
453 FALSE); |
18995
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
454 |
19046
8599a27ad69c
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19044
diff
changeset
|
455 ret = (pool->put_cert)(id, crt); |
8599a27ad69c
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19044
diff
changeset
|
456 |
19050
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
457 /* Signal that the certificate was stored if success*/ |
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
458 if (ret) { |
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
459 purple_signal_emit(pool, "certificate-stored", |
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
460 pool, id); |
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
461 } |
19046
8599a27ad69c
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19044
diff
changeset
|
462 |
8599a27ad69c
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19044
diff
changeset
|
463 return ret; |
18995
47b06daea9d1
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18993
diff
changeset
|
464 } |
18984
2b4150624cf2
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18982
diff
changeset
|
465 |
19049
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
466 gboolean |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
467 purple_certificate_pool_delete(PurpleCertificatePool *pool, const gchar *id) |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
468 { |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
469 gboolean ret = FALSE; |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
470 |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
471 g_return_val_if_fail(pool, FALSE); |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
472 g_return_val_if_fail(id, FALSE); |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
473 g_return_val_if_fail(pool->delete_cert, FALSE); |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
474 |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
475 ret = (pool->delete_cert)(id); |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
476 |
19050
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
477 /* Signal that the certificate was deleted if success */ |
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
478 if (ret) { |
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
479 purple_signal_emit(pool, "certificate-deleted", |
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
480 pool, id); |
c563b8f84aa0
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19049
diff
changeset
|
481 } |
19049
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
482 |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
483 return ret; |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
484 } |
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
485 |
19026
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
486 GList * |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
487 purple_certificate_pool_get_idlist(PurpleCertificatePool *pool) |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
488 { |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
489 g_return_val_if_fail(pool, NULL); |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
490 g_return_val_if_fail(pool->get_idlist, NULL); |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
491 |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
492 return (pool->get_idlist)(); |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
493 } |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
494 |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
495 void |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
496 purple_certificate_pool_destroy_idlist(GList *idlist) |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
497 { |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
498 GList *l; |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
499 |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
500 /* Iterate through and free them strings */ |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
501 for ( l = idlist; l; l = l->next ) { |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
502 g_free(l->data); |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
503 } |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
504 |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
505 g_list_free(idlist); |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
506 } |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
507 |
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
508 |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
509 /****************************************************************************/ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
510 /* Builtin Verifiers, Pools, etc. */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
511 /****************************************************************************/ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
512 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
513 static void |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
514 x509_singleuse_verify_cb (PurpleCertificateVerificationRequest *vrq, gint id) |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
515 { |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
516 g_return_if_fail(vrq); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
517 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
518 purple_debug_info("certificate/x509_singleuse", |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
519 "VRQ on cert from %s gave %d\n", |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
520 vrq->subject_name, id); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
521 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
522 /* Signal what happened back to the caller */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
523 if (1 == id) { |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
524 /* Accepted! */ |
19091
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
525 purple_certificate_verify_complete(vrq, |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
526 PURPLE_CERTIFICATE_VALID); |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
527 } else { |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
528 /* Not accepted */ |
19091
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
529 purple_certificate_verify_complete(vrq, |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
530 PURPLE_CERTIFICATE_INVALID); |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
531 |
19091
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
532 } |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
533 } |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
534 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
535 static void |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
536 x509_singleuse_start_verify (PurpleCertificateVerificationRequest *vrq) |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
537 { |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
538 gchar *sha_asc; |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
539 GByteArray *sha_bin; |
18964
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
540 gchar *cn; |
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
541 const gchar *cn_match; |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
542 gchar *primary, *secondary; |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
543 PurpleCertificate *crt = (PurpleCertificate *) vrq->cert_chain->data; |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
544 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
545 /* Pull out the SHA1 checksum */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
546 sha_bin = purple_certificate_get_fingerprint_sha1(crt); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
547 /* Now decode it for display */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
548 sha_asc = purple_base16_encode_chunked(sha_bin->data, |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
549 sha_bin->len); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
550 |
18964
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
551 /* Get the cert Common Name */ |
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
552 cn = purple_certificate_get_subject_name(crt); |
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
553 |
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
554 /* Determine whether the name matches */ |
19496
004c3e257bd0
- Even more TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19495
diff
changeset
|
555 if (purple_certificate_check_subject_name(crt, vrq->subject_name)) { |
20270
d94432a338ab
Translating the empty string is a bad idea.
Richard Laager <rlaager@wiktel.com>
parents:
20248
diff
changeset
|
556 cn_match = ""; |
18964
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
557 } else { |
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
558 cn_match = _("(DOES NOT MATCH)"); |
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
559 } |
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
560 |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
561 /* Make messages */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
562 primary = g_strdup_printf(_("%s has presented the following certificate for just-this-once use:"), vrq->subject_name); |
18964
7b03727b10b4
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18962
diff
changeset
|
563 secondary = g_strdup_printf(_("Common name: %s %s\nFingerprint (SHA1): %s"), cn, cn_match, sha_asc); |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
564 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
565 /* Make a semi-pretty display */ |
21095
cab348e39751
disapproval of revision '0e5385979f58d6ee74f668bb9b5dfd1ae3b6043f'
Richard Laager <rlaager@wiktel.com>
parents:
21086
diff
changeset
|
566 purple_request_accept_cancel_with_hint( |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
567 vrq->cb_data, /* TODO: Find what the handle ought to be */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
568 _("Single-use Certificate Verification"), |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
569 primary, |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
570 secondary, |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
571 1, /* Accept by default */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
572 NULL, /* No account */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
573 NULL, /* No other user */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
574 NULL, /* No associated conversation */ |
21244
a20ef7180680
Re-namespace the #defines to all be PURPLE_REQUEST_UI_HINT_*. I see no
Richard Laager <rlaager@wiktel.com>
parents:
21235
diff
changeset
|
575 PURPLE_REQUEST_UI_HINT_BLIST, |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
576 vrq, |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
577 x509_singleuse_verify_cb, |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
578 x509_singleuse_verify_cb ); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
579 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
580 /* Cleanup */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
581 g_free(primary); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
582 g_free(secondary); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
583 g_free(sha_asc); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
584 g_byte_array_free(sha_bin, TRUE); |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
585 } |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
586 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
587 static void |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
588 x509_singleuse_destroy_request (PurpleCertificateVerificationRequest *vrq) |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
589 { |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
590 /* I don't do anything! */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
591 } |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
592 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
593 PurpleCertificateVerifier x509_singleuse = { |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
594 "x509", /* Scheme name */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
595 "singleuse", /* Verifier name */ |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
596 x509_singleuse_start_verify, /* start_verification function */ |
19648
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
597 x509_singleuse_destroy_request, /* Request cleanup operation */ |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
598 |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
599 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
600 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
601 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
602 NULL |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
603 }; |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
604 |
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
605 |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
606 |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
607 /***** X.509 Certificate Authority pool, keyed by Distinguished Name *****/ |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
608 /* This is implemented in what may be the most inefficient and bugprone way |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
609 possible; however, future optimizations should not be difficult. */ |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
610 |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
611 static PurpleCertificatePool x509_ca; |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
612 |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
613 /** Holds a key-value pair for quickish certificate lookup */ |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
614 typedef struct { |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
615 gchar *dn; |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
616 PurpleCertificate *crt; |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
617 } x509_ca_element; |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
618 |
19207
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
619 static void |
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
620 x509_ca_element_free(x509_ca_element *el) |
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
621 { |
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
622 if (NULL == el) return; |
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
623 |
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
624 g_free(el->dn); |
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
625 purple_certificate_destroy(el->crt); |
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
626 g_free(el); |
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
627 } |
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
628 |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
629 /** System directory to probe for CA certificates */ |
19271
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
630 /* This is set in the lazy_init function */ |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
631 static const gchar *x509_ca_syspath = NULL; |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
632 |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
633 /** A list of loaded CAs, populated from the above path whenever the lazy_init |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
634 happens. Contains pointers to x509_ca_elements */ |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
635 static GList *x509_ca_certs = NULL; |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
636 |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
637 /** Used for lazy initialization purposes. */ |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
638 static gboolean x509_ca_initialized = FALSE; |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
639 |
19201
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
640 /** Adds a certificate to the in-memory cache, doing nothing else */ |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
641 static gboolean |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
642 x509_ca_quiet_put_cert(PurpleCertificate *crt) |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
643 { |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
644 x509_ca_element *el; |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
645 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
646 /* lazy_init calls this function, so calling lazy_init here is a |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
647 Bad Thing */ |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
648 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
649 g_return_val_if_fail(crt, FALSE); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
650 g_return_val_if_fail(crt->scheme, FALSE); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
651 /* Make sure that this is some kind of X.509 certificate */ |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
652 /* TODO: Perhaps just check crt->scheme->name instead? */ |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
653 g_return_val_if_fail(crt->scheme == purple_certificate_find_scheme(x509_ca.scheme_name), FALSE); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
654 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
655 el = g_new0(x509_ca_element, 1); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
656 el->dn = purple_certificate_get_unique_id(crt); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
657 el->crt = purple_certificate_copy(crt); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
658 x509_ca_certs = g_list_prepend(x509_ca_certs, el); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
659 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
660 return TRUE; |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
661 } |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
662 |
19271
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
663 /* Since the libpurple CertificatePools get registered before plugins are |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
664 loaded, an X.509 Scheme is generally not available when x509_ca_init is |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
665 called, but x509_ca requires X.509 operations in order to properly load. |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
666 |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
667 To solve this, I present the lazy_init function. It attempts to finish |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
668 initialization of the Pool, but it usually fails when it is called from |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
669 x509_ca_init. However, this is OK; initialization is then simply deferred |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
670 until someone tries to use functions from the pool. */ |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
671 static gboolean |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
672 x509_ca_lazy_init(void) |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
673 { |
19095
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
674 PurpleCertificateScheme *x509; |
19201
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
675 GDir *certdir; |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
676 const gchar *entry; |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
677 GPatternSpec *pempat; |
19095
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
678 |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
679 if (x509_ca_initialized) return TRUE; |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
680 |
19095
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
681 /* Check that X.509 is registered */ |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
682 x509 = purple_certificate_find_scheme(x509_ca.scheme_name); |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
683 if ( !x509 ) { |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
684 purple_debug_info("certificate/x509/ca", |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
685 "Lazy init failed because an X.509 Scheme " |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
686 "is not yet registered. Maybe it will be " |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
687 "better later.\n"); |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
688 return FALSE; |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
689 } |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
690 |
19271
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
691 /* Attempt to point at the appropriate system path */ |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
692 if (NULL == x509_ca_syspath) { |
19504
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
693 #ifdef _WIN32 |
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
694 x509_ca_syspath = g_build_filename(DATADIR, |
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
695 "ca-certs", NULL); |
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
696 #else |
19271
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
697 x509_ca_syspath = g_build_filename(DATADIR, |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
698 "purple", "ca-certs", NULL); |
19504
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
699 #endif |
19271
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
700 } |
c28e1afe691b
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19211
diff
changeset
|
701 |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
702 /* Populate the certificates pool from the system path */ |
19201
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
703 certdir = g_dir_open(x509_ca_syspath, 0, NULL); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
704 g_return_val_if_fail(certdir, FALSE); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
705 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
706 /* Use a glob to only read .pem files */ |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
707 pempat = g_pattern_spec_new("*.pem"); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
708 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
709 while ( (entry = g_dir_read_name(certdir)) ) { |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
710 gchar *fullpath; |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
711 PurpleCertificate *crt; |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
712 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
713 if ( !g_pattern_match_string(pempat, entry) ) { |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
714 continue; |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
715 } |
19095
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
716 |
19201
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
717 fullpath = g_build_filename(x509_ca_syspath, entry, NULL); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
718 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
719 /* TODO: Respond to a failure in the following? */ |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
720 crt = purple_certificate_import(x509, fullpath); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
721 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
722 if (x509_ca_quiet_put_cert(crt)) { |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
723 purple_debug_info("certificate/x509/ca", |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
724 "Loaded %s\n", |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
725 fullpath); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
726 } else { |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
727 purple_debug_error("certificate/x509/ca", |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
728 "Failed to load %s\n", |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
729 fullpath); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
730 } |
19210
74a3f6606cf6
- Fix memleak
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19209
diff
changeset
|
731 |
74a3f6606cf6
- Fix memleak
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19209
diff
changeset
|
732 purple_certificate_destroy(crt); |
19201
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
733 g_free(fullpath); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
734 } |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
735 |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
736 g_pattern_spec_free(pempat); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
737 g_dir_close(certdir); |
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
738 |
19095
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
739 purple_debug_info("certificate/x509/ca", |
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
740 "Lazy init completed.\n"); |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
741 x509_ca_initialized = TRUE; |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
742 return TRUE; |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
743 } |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
744 |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
745 static gboolean |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
746 x509_ca_init(void) |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
747 { |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
748 /* Attempt to initialize now, but if it doesn't work, that's OK; |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
749 it will get done later */ |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
750 if ( ! x509_ca_lazy_init()) { |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
751 purple_debug_info("certificate/x509/ca", |
19095
cd70e75f9a83
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19094
diff
changeset
|
752 "Init failed, probably because a " |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
753 "dependency is not yet registered. " |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
754 "It has been deferred to later.\n"); |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
755 } |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
756 |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
757 return TRUE; |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
758 } |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
759 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
760 static void |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
761 x509_ca_uninit(void) |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
762 { |
19202
c0949e081f43
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19201
diff
changeset
|
763 GList *l; |
c0949e081f43
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19201
diff
changeset
|
764 |
c0949e081f43
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19201
diff
changeset
|
765 for (l = x509_ca_certs; l; l = l->next) { |
c0949e081f43
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19201
diff
changeset
|
766 x509_ca_element *el = l->data; |
19207
8926e15873ca
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19206
diff
changeset
|
767 x509_ca_element_free(el); |
19202
c0949e081f43
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19201
diff
changeset
|
768 } |
c0949e081f43
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19201
diff
changeset
|
769 g_list_free(x509_ca_certs); |
c0949e081f43
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19201
diff
changeset
|
770 x509_ca_certs = NULL; |
c0949e081f43
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19201
diff
changeset
|
771 x509_ca_initialized = FALSE; |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
772 } |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
773 |
19203
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
774 /** Look up a ca_element by dn */ |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
775 static x509_ca_element * |
19205 | 776 x509_ca_locate_cert(GList *lst, const gchar *dn) |
19203
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
777 { |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
778 GList *cur; |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
779 |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
780 for (cur = lst; cur; cur = cur->next) { |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
781 x509_ca_element *el = cur->data; |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
782 /* TODO: Unsafe? */ |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
783 if ( !strcmp(dn, el->dn) ) { |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
784 return el; |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
785 } |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
786 } |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
787 return NULL; |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
788 } |
6034b8db9dc1
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19202
diff
changeset
|
789 |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
790 static gboolean |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
791 x509_ca_cert_in_pool(const gchar *id) |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
792 { |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
793 g_return_val_if_fail(x509_ca_lazy_init(), FALSE); |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
794 g_return_val_if_fail(id, FALSE); |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
795 |
19205 | 796 if (x509_ca_locate_cert(x509_ca_certs, id) != NULL) { |
19204
2847b6c84d6c
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19203
diff
changeset
|
797 return TRUE; |
2847b6c84d6c
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19203
diff
changeset
|
798 } else { |
2847b6c84d6c
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19203
diff
changeset
|
799 return FALSE; |
2847b6c84d6c
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19203
diff
changeset
|
800 } |
2847b6c84d6c
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19203
diff
changeset
|
801 |
2847b6c84d6c
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19203
diff
changeset
|
802 return FALSE; |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
803 } |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
804 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
805 static PurpleCertificate * |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
806 x509_ca_get_cert(const gchar *id) |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
807 { |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
808 PurpleCertificate *crt = NULL; |
19206
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
809 x509_ca_element *el; |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
810 |
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
811 g_return_val_if_fail(x509_ca_lazy_init(), NULL); |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
812 g_return_val_if_fail(id, NULL); |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
813 |
19206
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
814 /* Search the memory-cached pool */ |
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
815 el = x509_ca_locate_cert(x509_ca_certs, id); |
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
816 |
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
817 if (el != NULL) { |
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
818 /* Make a copy of the memcached one for the function caller |
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
819 to play with */ |
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
820 crt = purple_certificate_copy(el->crt); |
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
821 } else { |
919395a01483
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19205
diff
changeset
|
822 crt = NULL; |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
823 } |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
824 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
825 return crt; |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
826 } |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
827 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
828 static gboolean |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
829 x509_ca_put_cert(const gchar *id, PurpleCertificate *crt) |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
830 { |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
831 gboolean ret = FALSE; |
19201
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
832 |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
833 g_return_val_if_fail(x509_ca_lazy_init(), FALSE); |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
834 |
19096
81163e153778
- Add a hacked-up method of adding certs to the CA pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19095
diff
changeset
|
835 /* TODO: This is a quick way of doing this. At some point the change |
81163e153778
- Add a hacked-up method of adding certs to the CA pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19095
diff
changeset
|
836 ought to be flushed to disk somehow. */ |
19201
73d8dd2169c4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19096
diff
changeset
|
837 ret = x509_ca_quiet_put_cert(crt); |
19096
81163e153778
- Add a hacked-up method of adding certs to the CA pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19095
diff
changeset
|
838 |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
839 return ret; |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
840 } |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
841 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
842 static gboolean |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
843 x509_ca_delete_cert(const gchar *id) |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
844 { |
19208
7b81934f4c85
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19207
diff
changeset
|
845 x509_ca_element *el; |
7b81934f4c85
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19207
diff
changeset
|
846 |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
847 g_return_val_if_fail(x509_ca_lazy_init(), FALSE); |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
848 g_return_val_if_fail(id, FALSE); |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
849 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
850 /* Is the id even in the pool? */ |
19208
7b81934f4c85
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19207
diff
changeset
|
851 el = x509_ca_locate_cert(x509_ca_certs, id); |
7b81934f4c85
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19207
diff
changeset
|
852 if ( el == NULL ) { |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
853 purple_debug_warning("certificate/x509/ca", |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
854 "Id %s wasn't in the pool\n", |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
855 id); |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
856 return FALSE; |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
857 } |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
858 |
19208
7b81934f4c85
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19207
diff
changeset
|
859 /* Unlink it from the memory cache and destroy it */ |
7b81934f4c85
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19207
diff
changeset
|
860 x509_ca_certs = g_list_remove(x509_ca_certs, el); |
7b81934f4c85
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19207
diff
changeset
|
861 x509_ca_element_free(el); |
7b81934f4c85
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19207
diff
changeset
|
862 |
7b81934f4c85
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19207
diff
changeset
|
863 return TRUE; |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
864 } |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
865 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
866 static GList * |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
867 x509_ca_get_idlist(void) |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
868 { |
19209
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
869 GList *l, *idlist; |
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
870 |
19094
dd9f69ebaae8
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19093
diff
changeset
|
871 g_return_val_if_fail(x509_ca_lazy_init(), NULL); |
19209
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
872 |
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
873 idlist = NULL; |
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
874 for (l = x509_ca_certs; l; l = l->next) { |
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
875 x509_ca_element *el = l->data; |
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
876 idlist = g_list_prepend(idlist, g_strdup(el->dn)); |
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
877 } |
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
878 |
a6ab0ea47d0f
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19208
diff
changeset
|
879 return idlist; |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
880 } |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
881 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
882 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
883 static PurpleCertificatePool x509_ca = { |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
884 "x509", /* Scheme name */ |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
885 "ca", /* Pool name */ |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
886 N_("Certificate Authorities"),/* User-friendly name */ |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
887 NULL, /* Internal data */ |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
888 x509_ca_init, /* init */ |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
889 x509_ca_uninit, /* uninit */ |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
890 x509_ca_cert_in_pool, /* Certificate exists? */ |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
891 x509_ca_get_cert, /* Cert retriever */ |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
892 x509_ca_put_cert, /* Cert writer */ |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
893 x509_ca_delete_cert, /* Cert remover */ |
19648
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
894 x509_ca_get_idlist, /* idlist retriever */ |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
895 |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
896 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
897 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
898 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
899 NULL |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
900 |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
901 }; |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
902 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
903 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
904 |
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
905 /***** Cache of certificates given by TLS/SSL peers *****/ |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
906 static PurpleCertificatePool x509_tls_peers; |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
907 |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
908 static gboolean |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
909 x509_tls_peers_init(void) |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
910 { |
18985
806c610ac5a0
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18984
diff
changeset
|
911 gchar *poolpath; |
806c610ac5a0
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18984
diff
changeset
|
912 int ret; |
806c610ac5a0
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18984
diff
changeset
|
913 |
806c610ac5a0
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18984
diff
changeset
|
914 /* Set up key cache here if it isn't already done */ |
806c610ac5a0
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18984
diff
changeset
|
915 poolpath = purple_certificate_pool_mkpath(&x509_tls_peers, NULL); |
806c610ac5a0
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18984
diff
changeset
|
916 ret = purple_build_dir(poolpath, 0700); /* Make it this user only */ |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
917 |
18985
806c610ac5a0
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18984
diff
changeset
|
918 g_free(poolpath); |
806c610ac5a0
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18984
diff
changeset
|
919 |
806c610ac5a0
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18984
diff
changeset
|
920 g_return_val_if_fail(ret == 0, FALSE); |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
921 return TRUE; |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
922 } |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
923 |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
924 static gboolean |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
925 x509_tls_peers_cert_in_pool(const gchar *id) |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
926 { |
18987
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
927 gchar *keypath; |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
928 gboolean ret = FALSE; |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
929 |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
930 g_return_val_if_fail(id, FALSE); |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
931 |
18987
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
932 keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id); |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
933 |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
934 ret = g_file_test(keypath, G_FILE_TEST_IS_REGULAR); |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
935 |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
936 g_free(keypath); |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
937 return ret; |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
938 } |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
939 |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
940 static PurpleCertificate * |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
941 x509_tls_peers_get_cert(const gchar *id) |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
942 { |
18987
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
943 PurpleCertificateScheme *x509; |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
944 PurpleCertificate *crt; |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
945 gchar *keypath; |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
946 |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
947 g_return_val_if_fail(id, NULL); |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
948 |
18987
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
949 /* Is it in the pool? */ |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
950 if ( !x509_tls_peers_cert_in_pool(id) ) { |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
951 return NULL; |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
952 } |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
953 |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
954 /* Look up the X.509 scheme */ |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
955 x509 = purple_certificate_find_scheme("x509"); |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
956 g_return_val_if_fail(x509, NULL); |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
957 |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
958 /* Okay, now find and load that key */ |
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
959 keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id); |
18990
3f2944bdb404
- Finish tls_peers get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18989
diff
changeset
|
960 crt = purple_certificate_import(x509, keypath); |
18987
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
961 |
18990
3f2944bdb404
- Finish tls_peers get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18989
diff
changeset
|
962 g_free(keypath); |
18987
a763dd083b79
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18986
diff
changeset
|
963 |
18990
3f2944bdb404
- Finish tls_peers get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18989
diff
changeset
|
964 return crt; |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
965 } |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
966 |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
967 static gboolean |
18982
8948cd6bb8bc
- CertificatePool put_cert now accepts an id argument
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18977
diff
changeset
|
968 x509_tls_peers_put_cert(const gchar *id, PurpleCertificate *crt) |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
969 { |
18991
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
970 gboolean ret = FALSE; |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
971 gchar *keypath; |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
972 |
18991
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
973 g_return_val_if_fail(crt, FALSE); |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
974 g_return_val_if_fail(crt->scheme, FALSE); |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
975 /* Make sure that this is some kind of X.509 certificate */ |
18992
605e69fa7108
- Comment change
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18991
diff
changeset
|
976 /* TODO: Perhaps just check crt->scheme->name instead? */ |
18991
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
977 g_return_val_if_fail(crt->scheme == purple_certificate_find_scheme(x509_tls_peers.scheme_name), FALSE); |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
978 |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
979 /* Work out the filename and export */ |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
980 keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id); |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
981 ret = purple_certificate_export(keypath, crt); |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
982 |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
983 g_free(keypath); |
7a144f2229c6
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18990
diff
changeset
|
984 return ret; |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
985 } |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
986 |
19047
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
987 static gboolean |
19048
fd0b4b2f6cf0
- remove_cert => delete_cert, because naming conventions are our
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19047
diff
changeset
|
988 x509_tls_peers_delete_cert(const gchar *id) |
19047
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
989 { |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
990 gboolean ret = FALSE; |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
991 gchar *keypath; |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
992 |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
993 g_return_val_if_fail(id, FALSE); |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
994 |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
995 /* Is the id even in the pool? */ |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
996 if (!x509_tls_peers_cert_in_pool(id)) { |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
997 purple_debug_warning("certificate/tls_peers", |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
998 "Id %s wasn't in the pool\n", |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
999 id); |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1000 return FALSE; |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1001 } |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1002 |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1003 /* OK, so work out the keypath and delete the thing */ |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1004 keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id); |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1005 if ( unlink(keypath) != 0 ) { |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1006 purple_debug_error("certificate/tls_peers", |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1007 "Unlink of %s failed!\n", |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1008 keypath); |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1009 ret = FALSE; |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1010 } else { |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1011 ret = TRUE; |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1012 } |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1013 |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1014 g_free(keypath); |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1015 return ret; |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1016 } |
3af5d9ed9ad3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19046
diff
changeset
|
1017 |
19027
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1018 static GList * |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1019 x509_tls_peers_get_idlist(void) |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1020 { |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1021 GList *idlist = NULL; |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1022 GDir *dir; |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1023 const gchar *entry; |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1024 gchar *poolpath; |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1025 |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1026 /* Get a handle on the pool directory */ |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1027 poolpath = purple_certificate_pool_mkpath(&x509_tls_peers, NULL); |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1028 dir = g_dir_open(poolpath, |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1029 0, /* No flags */ |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1030 NULL); /* Not interested in what the error is */ |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1031 g_free(poolpath); |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1032 |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1033 g_return_val_if_fail(dir, NULL); |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1034 |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1035 /* Traverse the directory listing and create an idlist */ |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1036 while ( (entry = g_dir_read_name(dir)) != NULL ) { |
19078
3987f76c0e4b
- tls_peers pool unescapes filenames in its directory, as it should
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19077
diff
changeset
|
1037 /* Unescape the filename */ |
3987f76c0e4b
- tls_peers pool unescapes filenames in its directory, as it should
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19077
diff
changeset
|
1038 const char *unescaped = purple_unescape_filename(entry); |
3987f76c0e4b
- tls_peers pool unescapes filenames in its directory, as it should
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19077
diff
changeset
|
1039 |
19027
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1040 /* Copy the entry name into our list (GLib owns the original |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1041 string) */ |
19078
3987f76c0e4b
- tls_peers pool unescapes filenames in its directory, as it should
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19077
diff
changeset
|
1042 idlist = g_list_prepend(idlist, g_strdup(unescaped)); |
19027
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1043 } |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1044 |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1045 /* Release the directory */ |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1046 g_dir_close(dir); |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1047 |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1048 return idlist; |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1049 } |
15d9031e03b2
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
1050 |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1051 static PurpleCertificatePool x509_tls_peers = { |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1052 "x509", /* Scheme name */ |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1053 "tls_peers", /* Pool name */ |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1054 N_("SSL Peers Cache"), /* User-friendly name */ |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1055 NULL, /* Internal data */ |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1056 x509_tls_peers_init, /* init */ |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1057 NULL, /* uninit not required */ |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1058 x509_tls_peers_cert_in_pool, /* Certificate exists? */ |
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1059 x509_tls_peers_get_cert, /* Cert retriever */ |
19026
b3acaf46d9ad
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
1060 x509_tls_peers_put_cert, /* Cert writer */ |
19049
8cbc110456ac
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19048
diff
changeset
|
1061 x509_tls_peers_delete_cert, /* Cert remover */ |
19648
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1062 x509_tls_peers_get_idlist, /* idlist retriever */ |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1063 |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1064 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1065 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1066 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1067 NULL |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1068 }; |
18993
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1069 |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1070 |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
1071 /***** A Verifier that uses the tls_peers cache and the CA pool to validate certificates *****/ |
18993
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1072 static PurpleCertificateVerifier x509_tls_cached; |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1073 |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1074 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1075 /* The following is several hacks piled together and needs to be fixed. |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1076 * It exists because show_cert (see its comments) needs the original reason |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1077 * given to user_auth in order to rebuild the dialog. |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1078 */ |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1079 /* TODO: This will cause a ua_ctx to become memleaked if the request(s) get |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1080 closed by handle or otherwise abnormally. */ |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1081 typedef struct { |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1082 PurpleCertificateVerificationRequest *vrq; |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1083 gchar *reason; |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1084 } x509_tls_cached_ua_ctx; |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1085 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1086 static x509_tls_cached_ua_ctx * |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1087 x509_tls_cached_ua_ctx_new(PurpleCertificateVerificationRequest *vrq, |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1088 const gchar *reason) |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1089 { |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1090 x509_tls_cached_ua_ctx *c; |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1091 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1092 c = g_new0(x509_tls_cached_ua_ctx, 1); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1093 c->vrq = vrq; |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1094 c->reason = g_strdup(reason); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1095 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1096 return c; |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1097 } |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1098 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1099 |
18993
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1100 static void |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1101 x509_tls_cached_ua_ctx_free(x509_tls_cached_ua_ctx *c) |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1102 { |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1103 g_return_if_fail(c); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1104 g_free(c->reason); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1105 g_free(c); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1106 } |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1107 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1108 static void |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1109 x509_tls_cached_user_auth(PurpleCertificateVerificationRequest *vrq, |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1110 const gchar *reason); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1111 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1112 static void |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1113 x509_tls_cached_show_cert(x509_tls_cached_ua_ctx *c, gint id) |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1114 { |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1115 PurpleCertificate *disp_crt = c->vrq->cert_chain->data; |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1116 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1117 /* Since clicking a button closes the request, show it again */ |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1118 x509_tls_cached_user_auth(c->vrq, c->reason); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1119 |
19564
4a1812e1ec35
When you have a certificate dialog and you click on "View Certificate",
Mark Doliner <mark@kingant.net>
parents:
19553
diff
changeset
|
1120 /* Show the certificate AFTER re-opening the dialog so that this |
4a1812e1ec35
When you have a certificate dialog and you click on "View Certificate",
Mark Doliner <mark@kingant.net>
parents:
19553
diff
changeset
|
1121 appears above the other */ |
4a1812e1ec35
When you have a certificate dialog and you click on "View Certificate",
Mark Doliner <mark@kingant.net>
parents:
19553
diff
changeset
|
1122 purple_certificate_display_x509(disp_crt); |
4a1812e1ec35
When you have a certificate dialog and you click on "View Certificate",
Mark Doliner <mark@kingant.net>
parents:
19553
diff
changeset
|
1123 |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1124 x509_tls_cached_ua_ctx_free(c); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1125 } |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1126 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1127 static void |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1128 x509_tls_cached_user_auth_cb (x509_tls_cached_ua_ctx *c, gint id) |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1129 { |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1130 PurpleCertificateVerificationRequest *vrq; |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1131 PurpleCertificatePool *tls_peers; |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1132 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1133 g_return_if_fail(c); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1134 g_return_if_fail(c->vrq); |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1135 |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1136 vrq = c->vrq; |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1137 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1138 x509_tls_cached_ua_ctx_free(c); |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1139 |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1140 tls_peers = purple_certificate_find_pool("x509","tls_peers"); |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1141 |
19331
920984752314
- Fix the interpretation of the "accept cert? yes/no" choice id given by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19330
diff
changeset
|
1142 if (2 == id) { |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1143 gchar *cache_id = vrq->subject_name; |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1144 purple_debug_info("certificate/x509/tls_cached", |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1145 "User ACCEPTED cert\nCaching first in chain for future use as %s...\n", |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1146 cache_id); |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1147 |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1148 purple_certificate_pool_store(tls_peers, cache_id, |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1149 vrq->cert_chain->data); |
19091
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1150 |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1151 purple_certificate_verify_complete(vrq, |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1152 PURPLE_CERTIFICATE_VALID); |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1153 } else { |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1154 purple_debug_info("certificate/x509/tls_cached", |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1155 "User REJECTED cert\n"); |
19091
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1156 purple_certificate_verify_complete(vrq, |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1157 PURPLE_CERTIFICATE_INVALID); |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1158 } |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1159 } |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1160 |
19515
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1161 static void |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1162 x509_tls_cached_user_auth_accept_cb(x509_tls_cached_ua_ctx *c, gint ignore) |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1163 { |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1164 x509_tls_cached_user_auth_cb(c, 2); |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1165 } |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1166 |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1167 static void |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1168 x509_tls_cached_user_auth_reject_cb(x509_tls_cached_ua_ctx *c, gint ignore) |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1169 { |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1170 x509_tls_cached_user_auth_cb(c, 1); |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1171 } |
b62683f4120d
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19504
diff
changeset
|
1172 |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1173 /** Validates a certificate by asking the user |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1174 * @param reason String to explain why the user needs to accept/refuse the |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1175 * certificate. |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1176 * @todo Needs a handle argument |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1177 */ |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1178 static void |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1179 x509_tls_cached_user_auth(PurpleCertificateVerificationRequest *vrq, |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1180 const gchar *reason) |
19000
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1181 { |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1182 gchar *primary; |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1183 |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1184 /* Make messages */ |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1185 primary = g_strdup_printf(_("Accept certificate for %s?"), |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1186 vrq->subject_name); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1187 |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1188 /* Make a semi-pretty display */ |
21095
cab348e39751
disapproval of revision '0e5385979f58d6ee74f668bb9b5dfd1ae3b6043f'
Richard Laager <rlaager@wiktel.com>
parents:
21086
diff
changeset
|
1189 purple_request_action_with_hint( |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1190 vrq->cb_data, /* TODO: Find what the handle ought to be */ |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1191 _("SSL Certificate Verification"), |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1192 primary, |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1193 reason, |
19331
920984752314
- Fix the interpretation of the "accept cert? yes/no" choice id given by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19330
diff
changeset
|
1194 2, /* Accept by default */ |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1195 NULL, /* No account */ |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1196 NULL, /* No other user */ |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1197 NULL, /* No associated conversation */ |
21244
a20ef7180680
Re-namespace the #defines to all be PURPLE_REQUEST_UI_HINT_*. I see no
Richard Laager <rlaager@wiktel.com>
parents:
21235
diff
changeset
|
1198 PURPLE_REQUEST_UI_HINT_BLIST, |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1199 x509_tls_cached_ua_ctx_new(vrq, reason), |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1200 3, /* Number of actions */ |
19534
126c5235627b
- Change wording on certificate accept/reject dialog
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19517
diff
changeset
|
1201 _("Accept"), x509_tls_cached_user_auth_accept_cb, |
126c5235627b
- Change wording on certificate accept/reject dialog
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19517
diff
changeset
|
1202 _("Reject"), x509_tls_cached_user_auth_reject_cb, |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1203 _("_View Certificate..."), x509_tls_cached_show_cert); |
19001
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1204 |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1205 /* Cleanup */ |
b207701cb5a3
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1206 g_free(primary); |
19000
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1207 } |
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1208 |
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1209 static void |
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1210 x509_tls_cached_peer_cert_changed(PurpleCertificateVerificationRequest *vrq) |
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1211 { |
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1212 /* TODO: Prompt the user, etc. */ |
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1213 |
19091
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1214 purple_debug_info("certificate/x509/tls_cached", |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1215 "Certificate for %s does not match cached. " |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1216 "Auto-rejecting!\n", |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1217 vrq->subject_name); |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1218 |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1219 purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_INVALID); |
19000
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1220 return; |
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1221 } |
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1222 |
19086
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1223 static void |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1224 x509_tls_cached_cert_in_cache(PurpleCertificateVerificationRequest *vrq) |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1225 { |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1226 /* TODO: Looking this up by name over and over is expensive. |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1227 Fix, please! */ |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1228 PurpleCertificatePool *tls_peers = |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1229 purple_certificate_find_pool(x509_tls_cached.scheme_name, |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1230 "tls_peers"); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1231 |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1232 /* The peer's certificate should be the first in the list */ |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1233 PurpleCertificate *peer_crt = |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1234 (PurpleCertificate *) vrq->cert_chain->data; |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1235 |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1236 PurpleCertificate *cached_crt; |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1237 GByteArray *peer_fpr, *cached_fpr; |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1238 |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1239 /* Load up the cached certificate */ |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1240 cached_crt = purple_certificate_pool_retrieve( |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1241 tls_peers, vrq->subject_name); |
19553
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1242 if ( !cached_crt ) { |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1243 purple_debug_error("certificate/x509/tls_cached", |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1244 "Lookup failed on cached certificate!\n" |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1245 "It was here just a second ago. Forwarding " |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1246 "to cert_changed.\n"); |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1247 /* vrq now becomes the problem of cert_changed */ |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1248 x509_tls_cached_peer_cert_changed(vrq); |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1249 } |
19086
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1250 |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1251 /* Now get SHA1 sums for both and compare them */ |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1252 /* TODO: This is not an elegant way to compare certs */ |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1253 peer_fpr = purple_certificate_get_fingerprint_sha1(peer_crt); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1254 cached_fpr = purple_certificate_get_fingerprint_sha1(cached_crt); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1255 if (!memcmp(peer_fpr->data, cached_fpr->data, peer_fpr->len)) { |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1256 purple_debug_info("certificate/x509/tls_cached", |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1257 "Peer cert matched cached\n"); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1258 /* vrq is now finished */ |
19091
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1259 purple_certificate_verify_complete(vrq, |
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1260 PURPLE_CERTIFICATE_VALID); |
19086
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1261 } else { |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1262 purple_debug_info("certificate/x509/tls_cached", |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1263 "Peer cert did NOT match cached\n"); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1264 /* vrq now becomes the problem of cert_changed */ |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1265 x509_tls_cached_peer_cert_changed(vrq); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1266 } |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1267 |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1268 purple_certificate_destroy(cached_crt); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1269 g_byte_array_free(peer_fpr, TRUE); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1270 g_byte_array_free(cached_fpr, TRUE); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1271 } |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1272 |
19085
1bd9557f866e
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19084
diff
changeset
|
1273 /* For when we've never communicated with this party before */ |
19687
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1274 /* TODO: Need ways to specify possibly multiple problems with a cert, or at |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1275 least reprioritize them. For example, maybe the signature ought to be |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1276 checked BEFORE the hostname checking? */ |
19085
1bd9557f866e
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19084
diff
changeset
|
1277 static void |
1bd9557f866e
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19084
diff
changeset
|
1278 x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq) |
1bd9557f866e
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19084
diff
changeset
|
1279 { |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1280 PurpleCertificatePool *ca, *tls_peers; |
19090
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1281 PurpleCertificate *end_crt, *ca_crt, *peer_crt; |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1282 GList *chain = vrq->cert_chain; |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1283 GList *last; |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1284 gchar *ca_id; |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1285 |
19090
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1286 peer_crt = (PurpleCertificate *) chain->data; |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1287 |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1288 /* First, check that the hostname matches */ |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1289 if ( ! purple_certificate_check_subject_name(peer_crt, |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1290 vrq->subject_name) ) { |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1291 gchar *sn = purple_certificate_get_subject_name(peer_crt); |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1292 gchar *msg; |
19090
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1293 |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1294 purple_debug_info("certificate/x509/tls_cached", |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1295 "Name mismatch: Certificate given for %s " |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1296 "has a name of %s\n", |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1297 vrq->subject_name, sn); |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1298 |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1299 /* Prompt the user to authenticate the certificate */ |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1300 /* TODO: Provide the user with more guidance about why he is |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1301 being prompted */ |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1302 /* vrq will be completed by user_auth */ |
19495
5aaff16e9fbb
- Reword some dialogs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19332
diff
changeset
|
1303 msg = g_strdup_printf(_("The certificate presented by \"%s\" " |
5aaff16e9fbb
- Reword some dialogs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19332
diff
changeset
|
1304 "claims to be from \"%s\" instead. " |
5aaff16e9fbb
- Reword some dialogs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19332
diff
changeset
|
1305 "This could mean that you are not " |
5aaff16e9fbb
- Reword some dialogs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19332
diff
changeset
|
1306 "connecting to the service you " |
5aaff16e9fbb
- Reword some dialogs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19332
diff
changeset
|
1307 "believe you are."), |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1308 vrq->subject_name, sn); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1309 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1310 x509_tls_cached_user_auth(vrq,msg); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1311 |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1312 g_free(sn); |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1313 g_free(msg); |
19090
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1314 return; |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1315 } /* if (name mismatch) */ |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1316 |
19687
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1317 /* TODO: Figure out a way to check for a bad signature, as opposed to |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1318 "not self-signed" */ |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1319 if ( purple_certificate_signed_by(peer_crt, peer_crt) ) { |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1320 gchar *msg; |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1321 |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1322 purple_debug_info("certificate/x509/tls_cached", |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1323 "Certificate for %s is self-signed.\n", |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1324 vrq->subject_name); |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1325 |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1326 /* Prompt the user to authenticate the certificate */ |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1327 /* vrq will be completed by user_auth */ |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1328 msg = g_strdup_printf(_("The certificate presented by \"%s\" " |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1329 "is self-signed. It cannot be " |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1330 "automatically checked."), |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1331 vrq->subject_name); |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1332 |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1333 x509_tls_cached_user_auth(vrq,msg); |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1334 |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1335 g_free(msg); |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1336 return; |
936f4de347c3
- Add specific notification for self-signed certificates. Fixes #2874
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19680
diff
changeset
|
1337 } /* if (name mismatch) */ |
19090
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1338 |
5310b1294287
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19089
diff
changeset
|
1339 /* Next, check that the certificate chain is valid */ |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1340 if ( ! purple_certificate_check_signature_chain(chain) ) { |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1341 /* TODO: Tell the user where the chain broke? */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1342 /* TODO: This error will hopelessly confuse any |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1343 non-elite user. */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1344 gchar *secondary; |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1345 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1346 secondary = g_strdup_printf(_("The certificate chain presented" |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1347 " for %s is not valid."), |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1348 vrq->subject_name); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1349 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1350 /* TODO: Make this error either block the ensuing SSL |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1351 connection error until the user dismisses this one, or |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1352 stifle it. */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1353 purple_notify_error(NULL, /* TODO: Probably wrong. */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1354 _("SSL Certificate Error"), |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1355 _("Invalid certificate chain"), |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1356 secondary ); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1357 g_free(secondary); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1358 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1359 /* Okay, we're done here */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1360 purple_certificate_verify_complete(vrq, |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1361 PURPLE_CERTIFICATE_INVALID); |
21553
5cd93ff08ecc
Don't crash when connecting to jabber.freenet.de. Michael Weitzel sent
Mark Doliner <mark@kingant.net>
parents:
21244
diff
changeset
|
1362 return; |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1363 } /* if (signature chain not good) */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1364 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1365 /* Next, attempt to verify the last certificate against a CA */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1366 ca = purple_certificate_find_pool(x509_tls_cached.scheme_name, "ca"); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1367 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1368 /* If, for whatever reason, there is no Certificate Authority pool |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1369 loaded, we will simply present it to the user for checking. */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1370 if ( !ca ) { |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1371 purple_debug_error("certificate/x509/tls_cached", |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1372 "No X.509 Certificate Authority pool " |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1373 "could be found!\n"); |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1374 |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1375 /* vrq will be completed by user_auth */ |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1376 x509_tls_cached_user_auth(vrq,_("You have no database of root " |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1377 "certificates, so this " |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1378 "certificate cannot be " |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1379 "validated.")); |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1380 return; |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1381 } |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1382 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1383 last = g_list_last(chain); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1384 end_crt = (PurpleCertificate *) last->data; |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1385 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1386 /* Attempt to look up the last certificate's issuer */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1387 ca_id = purple_certificate_get_issuer_unique_id(end_crt); |
19211
8b2b9765fe64
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19210
diff
changeset
|
1388 purple_debug_info("certificate/x509/tls_cached", |
8b2b9765fe64
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19210
diff
changeset
|
1389 "Checking for a CA with DN=%s\n", |
8b2b9765fe64
- Add debugging babble
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19210
diff
changeset
|
1390 ca_id); |
20746
27f85efa6505
- Use certificate_pool_retrieve instead of certificate_pool_contains and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20270
diff
changeset
|
1391 ca_crt = purple_certificate_pool_retrieve(ca, ca_id); |
27f85efa6505
- Use certificate_pool_retrieve instead of certificate_pool_contains and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20270
diff
changeset
|
1392 if ( NULL == ca_crt ) { |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1393 purple_debug_info("certificate/x509/tls_cached", |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1394 "Certificate Authority with DN='%s' not " |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1395 "found. I'll prompt the user, I guess.\n", |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1396 ca_id); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1397 g_free(ca_id); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1398 /* vrq will be completed by user_auth */ |
19330
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1399 x509_tls_cached_user_auth(vrq,_("The root certificate this " |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1400 "one claims to be issued by " |
b65a23799dc2
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19329
diff
changeset
|
1401 "is unknown to Pidgin.")); |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1402 return; |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1403 } |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1404 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1405 g_free(ca_id); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1406 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1407 /* Check the signature */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1408 if ( !purple_certificate_signed_by(end_crt, ca_crt) ) { |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1409 /* TODO: If signed_by ever returns a reason, maybe mention |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1410 that, too. */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1411 /* TODO: Also mention the CA involved. While I could do this |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1412 now, a full DN is a little much with which to assault the |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1413 user's poor, leaky eyes. */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1414 /* TODO: This error message makes my eyes cross, and I wrote it */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1415 gchar * secondary = |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1416 g_strdup_printf(_("The certificate chain presented by " |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1417 "%s does not have a valid digital " |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1418 "signature from the Certificate " |
19495
5aaff16e9fbb
- Reword some dialogs
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19332
diff
changeset
|
1419 "Authority from which it claims to " |
19497
d351a42435a9
- TODO whacking and cosmetics
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19496
diff
changeset
|
1420 "have a signature."), |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1421 vrq->subject_name); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1422 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1423 purple_notify_error(NULL, /* TODO: Probably wrong */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1424 _("SSL Certificate Error"), |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1425 _("Invalid certificate authority" |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1426 " signature"), |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1427 secondary); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1428 g_free(secondary); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1429 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1430 /* Signal "bad cert" */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1431 purple_certificate_verify_complete(vrq, |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1432 PURPLE_CERTIFICATE_INVALID); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1433 return; |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1434 } /* if (CA signature not good) */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1435 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1436 /* If we reach this point, the certificate is good. */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1437 /* Look up the local cache and store it there for future use */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1438 tls_peers = purple_certificate_find_pool(x509_tls_cached.scheme_name, |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1439 "tls_peers"); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1440 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1441 if (tls_peers) { |
19553
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1442 if (!purple_certificate_pool_store(tls_peers,vrq->subject_name, |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1443 peer_crt) ) { |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1444 purple_debug_error("certificate/x509/tls_cached", |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1445 "FAILED to cache peer certificate\n"); |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1446 } |
19089
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1447 } else { |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1448 purple_debug_error("certificate/x509/tls_cached", |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1449 "Unable to locate tls_peers certificate " |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1450 "cache.\n"); |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1451 } |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1452 |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1453 /* Whew! Done! */ |
c8962b52579e
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19088
diff
changeset
|
1454 purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_VALID); |
19085
1bd9557f866e
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19084
diff
changeset
|
1455 } |
1bd9557f866e
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19084
diff
changeset
|
1456 |
19000
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1457 static void |
18993
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1458 x509_tls_cached_start_verify(PurpleCertificateVerificationRequest *vrq) |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1459 { |
18999
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1460 const gchar *tls_peers_name = "tls_peers"; /* Name of local cache */ |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1461 PurpleCertificatePool *tls_peers; |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1462 |
18993
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1463 g_return_if_fail(vrq); |
18999
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1464 |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1465 purple_debug_info("certificate/x509/tls_cached", |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1466 "Starting verify for %s\n", |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1467 vrq->subject_name); |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1468 |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1469 tls_peers = purple_certificate_find_pool(x509_tls_cached.scheme_name,tls_peers_name); |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1470 |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1471 if (!tls_peers) { |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1472 purple_debug_error("certificate/x509/tls_cached", |
20247
e6315ec87124
applied changes from 92e6c32278d711f0d5807c4d931b26162e4a720f
Richard Laager <rlaager@wiktel.com>
parents:
19687
diff
changeset
|
1473 "Couldn't find local peers cache %s\nPrompting the user\n", |
18999
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1474 tls_peers_name); |
19091
489889091b14
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19090
diff
changeset
|
1475 |
20247
e6315ec87124
applied changes from 92e6c32278d711f0d5807c4d931b26162e4a720f
Richard Laager <rlaager@wiktel.com>
parents:
19687
diff
changeset
|
1476 |
e6315ec87124
applied changes from 92e6c32278d711f0d5807c4d931b26162e4a720f
Richard Laager <rlaager@wiktel.com>
parents:
19687
diff
changeset
|
1477 /* vrq now becomes the problem of unknown_peer */ |
e6315ec87124
applied changes from 92e6c32278d711f0d5807c4d931b26162e4a720f
Richard Laager <rlaager@wiktel.com>
parents:
19687
diff
changeset
|
1478 x509_tls_cached_unknown_peer(vrq); |
18999
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1479 return; |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1480 } |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1481 |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1482 /* Check if the peer has a certificate cached already */ |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1483 purple_debug_info("certificate/x509/tls_cached", |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1484 "Checking for cached cert...\n"); |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1485 if (purple_certificate_pool_contains(tls_peers, vrq->subject_name)) { |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1486 purple_debug_info("certificate/x509/tls_cached", |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1487 "...Found cached cert\n"); |
19086
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1488 /* vrq is now the responsibility of cert_in_cache */ |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1489 x509_tls_cached_cert_in_cache(vrq); |
e256e0bf8ae1
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19085
diff
changeset
|
1490 } else { |
18999
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1491 purple_debug_info("certificate/x509/tls_cached", |
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1492 "...Not in cache\n"); |
19000
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1493 /* vrq now becomes the problem of unknown_peer */ |
986413850713
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18999
diff
changeset
|
1494 x509_tls_cached_unknown_peer(vrq); |
18999
7fbd0a6ac8d6
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18996
diff
changeset
|
1495 } |
18993
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1496 } |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1497 |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1498 static void |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1499 x509_tls_cached_destroy_request(PurpleCertificateVerificationRequest *vrq) |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1500 { |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1501 g_return_if_fail(vrq); |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1502 } |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1503 |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1504 static PurpleCertificateVerifier x509_tls_cached = { |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1505 "x509", /* Scheme name */ |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1506 "tls_cached", /* Verifier name */ |
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1507 x509_tls_cached_start_verify, /* Verification begin */ |
19648
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1508 x509_tls_cached_destroy_request,/* Request cleanup */ |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1509 |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1510 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1511 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1512 NULL, |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1513 NULL |
450f4a3c4c0f
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19564
diff
changeset
|
1514 |
18993
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1515 }; |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1516 |
18950
f78a9efa9eaf
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18949
diff
changeset
|
1517 /****************************************************************************/ |
f78a9efa9eaf
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18949
diff
changeset
|
1518 /* Subsystem */ |
f78a9efa9eaf
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18949
diff
changeset
|
1519 /****************************************************************************/ |
f78a9efa9eaf
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18949
diff
changeset
|
1520 void |
18957
9205841eed06
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18953
diff
changeset
|
1521 purple_certificate_init(void) |
18950
f78a9efa9eaf
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18949
diff
changeset
|
1522 { |
18957
9205841eed06
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18953
diff
changeset
|
1523 /* Register builtins */ |
18953
89b32569890c
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18952
diff
changeset
|
1524 purple_certificate_register_verifier(&x509_singleuse); |
19093
f96b53df8d17
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19092
diff
changeset
|
1525 purple_certificate_register_pool(&x509_ca); |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1526 purple_certificate_register_pool(&x509_tls_peers); |
18993
33fb4930ad2b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18992
diff
changeset
|
1527 purple_certificate_register_verifier(&x509_tls_cached); |
18950
f78a9efa9eaf
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18949
diff
changeset
|
1528 } |
18946
617447a71ab7
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18943
diff
changeset
|
1529 |
18957
9205841eed06
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18953
diff
changeset
|
1530 void |
9205841eed06
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18953
diff
changeset
|
1531 purple_certificate_uninit(void) |
9205841eed06
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18953
diff
changeset
|
1532 { |
19024
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1533 GList *full_list, *l; |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1534 |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1535 /* Unregister all Schemes */ |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1536 full_list = g_list_copy(cert_schemes); /* Make a working copy */ |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1537 for (l = full_list; l; l = l->next) { |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1538 purple_certificate_unregister_scheme( |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1539 (PurpleCertificateScheme *) l->data ); |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1540 } |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1541 g_list_free(full_list); |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1542 |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1543 /* Unregister all Verifiers */ |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1544 full_list = g_list_copy(cert_verifiers); /* Make a working copy */ |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1545 for (l = full_list; l; l = l->next) { |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1546 purple_certificate_unregister_verifier( |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1547 (PurpleCertificateVerifier *) l->data ); |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1548 } |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1549 g_list_free(full_list); |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1550 |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1551 /* Unregister all Pools */ |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1552 full_list = g_list_copy(cert_pools); /* Make a working copy */ |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1553 for (l = full_list; l; l = l->next) { |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1554 purple_certificate_unregister_pool( |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1555 (PurpleCertificatePool *) l->data ); |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1556 } |
264f00bc8f22
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19023
diff
changeset
|
1557 g_list_free(full_list); |
18957
9205841eed06
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18953
diff
changeset
|
1558 } |
9205841eed06
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18953
diff
changeset
|
1559 |
19022
1f07f96dc1ce
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19021
diff
changeset
|
1560 gpointer |
1f07f96dc1ce
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19021
diff
changeset
|
1561 purple_certificate_get_handle(void) |
1f07f96dc1ce
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19021
diff
changeset
|
1562 { |
1f07f96dc1ce
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19021
diff
changeset
|
1563 static gint handle; |
1f07f96dc1ce
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19021
diff
changeset
|
1564 return &handle; |
1f07f96dc1ce
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19021
diff
changeset
|
1565 } |
1f07f96dc1ce
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19021
diff
changeset
|
1566 |
18192
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1567 PurpleCertificateScheme * |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1568 purple_certificate_find_scheme(const gchar *name) |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1569 { |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1570 PurpleCertificateScheme *scheme = NULL; |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1571 GList *l; |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1572 |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1573 g_return_val_if_fail(name, NULL); |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1574 |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1575 /* Traverse the list of registered schemes and locate the |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1576 one whose name matches */ |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1577 for(l = cert_schemes; l; l = l->next) { |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1578 scheme = (PurpleCertificateScheme *)(l->data); |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1579 |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1580 /* Name matches? that's our man */ |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1581 if(!g_ascii_strcasecmp(scheme->name, name)) |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1582 return scheme; |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1583 } |
17638
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1584 |
18192
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1585 purple_debug_warning("certificate", |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1586 "CertificateScheme %s requested but not found.\n", |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1587 name); |
17638
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1588 |
18192
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1589 /* TODO: Signalling and such? */ |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1590 |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1591 return NULL; |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1592 } |
17638
668a294f9a72
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1593 |
19023
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1594 GList * |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1595 purple_certificate_get_schemes(void) |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1596 { |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1597 return cert_schemes; |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1598 } |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1599 |
18192
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1600 gboolean |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1601 purple_certificate_register_scheme(PurpleCertificateScheme *scheme) |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1602 { |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1603 g_return_val_if_fail(scheme != NULL, FALSE); |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1604 |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1605 /* Make sure no scheme is registered with the same name */ |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1606 if (purple_certificate_find_scheme(scheme->name) != NULL) { |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1607 return FALSE; |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1608 } |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1609 |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1610 /* Okay, we're golden. Register it. */ |
18972
486563a6bb5c
- prepend > append
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18971
diff
changeset
|
1611 cert_schemes = g_list_prepend(cert_schemes, scheme); |
18192
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1612 |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1613 /* TODO: Signalling and such? */ |
19063
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1614 |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1615 purple_debug_info("certificate", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1616 "CertificateScheme %s registered\n", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1617 scheme->name); |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1618 |
18192
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1619 return TRUE; |
dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17641
diff
changeset
|
1620 } |
18926
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1621 |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1622 gboolean |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1623 purple_certificate_unregister_scheme(PurpleCertificateScheme *scheme) |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1624 { |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1625 if (NULL == scheme) { |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1626 purple_debug_warning("certificate", |
18973
28673b6fb8a2
- Fix some errors and return values
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18972
diff
changeset
|
1627 "Attempting to unregister NULL scheme\n"); |
28673b6fb8a2
- Fix some errors and return values
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18972
diff
changeset
|
1628 return FALSE; |
18926
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1629 } |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1630 |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1631 /* TODO: signalling? */ |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1632 |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1633 /* TODO: unregister all CertificateVerifiers for this scheme?*/ |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1634 /* TODO: unregister all CertificatePools for this scheme? */ |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1635 /* Neither of the above should be necessary, though */ |
18926
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1636 cert_schemes = g_list_remove(cert_schemes, scheme); |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1637 |
19063
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1638 purple_debug_info("certificate", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1639 "CertificateScheme %s unregistered\n", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1640 scheme->name); |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1641 |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1642 |
18926
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1643 return TRUE; |
8c4d52bc0319
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18192
diff
changeset
|
1644 } |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1645 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1646 PurpleCertificateVerifier * |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1647 purple_certificate_find_verifier(const gchar *scheme_name, const gchar *ver_name) |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1648 { |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1649 PurpleCertificateVerifier *vr = NULL; |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1650 GList *l; |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1651 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1652 g_return_val_if_fail(scheme_name, NULL); |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1653 g_return_val_if_fail(ver_name, NULL); |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1654 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1655 /* Traverse the list of registered verifiers and locate the |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1656 one whose name matches */ |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1657 for(l = cert_verifiers; l; l = l->next) { |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1658 vr = (PurpleCertificateVerifier *)(l->data); |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1659 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1660 /* Scheme and name match? */ |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1661 if(!g_ascii_strcasecmp(vr->scheme_name, scheme_name) && |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1662 !g_ascii_strcasecmp(vr->name, ver_name)) |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1663 return vr; |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1664 } |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1665 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1666 purple_debug_warning("certificate", |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1667 "CertificateVerifier %s, %s requested but not found.\n", |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1668 scheme_name, ver_name); |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1669 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1670 /* TODO: Signalling and such? */ |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1671 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1672 return NULL; |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1673 } |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1674 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1675 |
19023
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1676 GList * |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1677 purple_certificate_get_verifiers(void) |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1678 { |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1679 return cert_verifiers; |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1680 } |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1681 |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1682 gboolean |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1683 purple_certificate_register_verifier(PurpleCertificateVerifier *vr) |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1684 { |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1685 g_return_val_if_fail(vr != NULL, FALSE); |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1686 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1687 /* Make sure no verifier is registered with the same scheme/name */ |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1688 if (purple_certificate_find_verifier(vr->scheme_name, vr->name) != NULL) { |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1689 return FALSE; |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1690 } |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1691 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1692 /* Okay, we're golden. Register it. */ |
18972
486563a6bb5c
- prepend > append
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18971
diff
changeset
|
1693 cert_verifiers = g_list_prepend(cert_verifiers, vr); |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1694 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1695 /* TODO: Signalling and such? */ |
19063
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1696 |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1697 purple_debug_info("certificate", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1698 "CertificateVerifier %s registered\n", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1699 vr->name); |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1700 return TRUE; |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1701 } |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1702 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1703 gboolean |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1704 purple_certificate_unregister_verifier(PurpleCertificateVerifier *vr) |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1705 { |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1706 if (NULL == vr) { |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1707 purple_debug_warning("certificate", |
18973
28673b6fb8a2
- Fix some errors and return values
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18972
diff
changeset
|
1708 "Attempting to unregister NULL verifier\n"); |
28673b6fb8a2
- Fix some errors and return values
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18972
diff
changeset
|
1709 return FALSE; |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1710 } |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1711 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1712 /* TODO: signalling? */ |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1713 |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1714 cert_verifiers = g_list_remove(cert_verifiers, vr); |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1715 |
19063
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1716 |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1717 purple_debug_info("certificate", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1718 "CertificateVerifier %s unregistered\n", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1719 vr->name); |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1720 |
18941
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1721 return TRUE; |
425f494bd1ec
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18926
diff
changeset
|
1722 } |
18971
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1723 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1724 PurpleCertificatePool * |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1725 purple_certificate_find_pool(const gchar *scheme_name, const gchar *pool_name) |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1726 { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1727 PurpleCertificatePool *pool = NULL; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1728 GList *l; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1729 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1730 g_return_val_if_fail(scheme_name, NULL); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1731 g_return_val_if_fail(pool_name, NULL); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1732 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1733 /* Traverse the list of registered pools and locate the |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1734 one whose name matches */ |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1735 for(l = cert_pools; l; l = l->next) { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1736 pool = (PurpleCertificatePool *)(l->data); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1737 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1738 /* Scheme and name match? */ |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1739 if(!g_ascii_strcasecmp(pool->scheme_name, scheme_name) && |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1740 !g_ascii_strcasecmp(pool->name, pool_name)) |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1741 return pool; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1742 } |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1743 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1744 purple_debug_warning("certificate", |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1745 "CertificatePool %s, %s requested but not found.\n", |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1746 scheme_name, pool_name); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1747 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1748 /* TODO: Signalling and such? */ |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1749 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1750 return NULL; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1751 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1752 } |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1753 |
19023
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1754 GList * |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1755 purple_certificate_get_pools(void) |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1756 { |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1757 return cert_pools; |
eb86ff3ba21a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19022
diff
changeset
|
1758 } |
18971
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1759 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1760 gboolean |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1761 purple_certificate_register_pool(PurpleCertificatePool *pool) |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1762 { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1763 gboolean success = FALSE; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1764 g_return_val_if_fail(pool, FALSE); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1765 g_return_val_if_fail(pool->scheme_name, FALSE); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1766 g_return_val_if_fail(pool->name, FALSE); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1767 g_return_val_if_fail(pool->fullname, FALSE); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1768 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1769 /* Make sure no pools are registered under this name */ |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1770 if (purple_certificate_find_pool(pool->scheme_name, pool->name)) { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1771 return FALSE; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1772 } |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1773 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1774 /* Initialize the pool if needed */ |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1775 if (pool->init) { |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1776 success = pool->init(); |
18971
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1777 } else { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1778 success = TRUE; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1779 } |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1780 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1781 if (success) { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1782 /* Register the Pool */ |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1783 cert_pools = g_list_prepend(cert_pools, pool); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1784 |
19044
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1785 /* TODO: Emit a signal that the pool got registered */ |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1786 |
19517
7bea9c9fd2a5
(Un)Register the pools with DBus to avoid a runtime fit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19515
diff
changeset
|
1787 PURPLE_DBUS_REGISTER_POINTER(pool, PurpleCertificatePool); |
19044
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1788 purple_signal_register(pool, /* Signals emitted from pool */ |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1789 "certificate-stored", |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1790 purple_marshal_VOID__POINTER_POINTER, |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1791 NULL, /* No callback return value */ |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1792 2, /* Two non-data arguments */ |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1793 purple_value_new(PURPLE_TYPE_SUBTYPE, |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1794 PURPLE_SUBTYPE_CERTIFICATEPOOL), |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1795 purple_value_new(PURPLE_TYPE_STRING)); |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1796 |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1797 purple_signal_register(pool, /* Signals emitted from pool */ |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1798 "certificate-deleted", |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1799 purple_marshal_VOID__POINTER_POINTER, |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1800 NULL, /* No callback return value */ |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1801 2, /* Two non-data arguments */ |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1802 purple_value_new(PURPLE_TYPE_SUBTYPE, |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1803 PURPLE_SUBTYPE_CERTIFICATEPOOL), |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1804 purple_value_new(PURPLE_TYPE_STRING)); |
19063
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1805 |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1806 |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1807 purple_debug_info("certificate", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1808 "CertificatePool %s registered\n", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1809 pool->name); |
18971
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1810 return TRUE; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1811 } else { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1812 return FALSE; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1813 } |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1814 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1815 /* Control does not reach this point */ |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1816 } |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1817 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1818 gboolean |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1819 purple_certificate_unregister_pool(PurpleCertificatePool *pool) |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1820 { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1821 if (NULL == pool) { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1822 purple_debug_warning("certificate", |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1823 "Attempting to unregister NULL pool\n"); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1824 return FALSE; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1825 } |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1826 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1827 /* Check that the pool is registered */ |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1828 if (!g_list_find(cert_pools, pool)) { |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1829 purple_debug_warning("certificate", |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1830 "Pool to unregister isn't registered!\n"); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1831 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1832 return FALSE; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1833 } |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1834 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1835 /* Uninit the pool if needed */ |
19517
7bea9c9fd2a5
(Un)Register the pools with DBus to avoid a runtime fit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19515
diff
changeset
|
1836 PURPLE_DBUS_UNREGISTER_POINTER(pool); |
18971
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1837 if (pool->uninit) { |
18975
172b8d1dc2be
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18973
diff
changeset
|
1838 pool->uninit(); |
18971
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1839 } |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1840 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1841 cert_pools = g_list_remove(cert_pools, pool); |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1842 |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1843 /* TODO: Signalling? */ |
19044
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1844 purple_signal_unregister(pool, "certificate-stored"); |
602295db8e6b
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
1845 purple_signal_unregister(pool, "certificate-deleted"); |
18971
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1846 |
19063
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1847 purple_debug_info("certificate", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1848 "CertificatePool %s unregistered\n", |
2f51578e6602
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19060
diff
changeset
|
1849 pool->name); |
18971
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1850 return TRUE; |
898e2bd70f23
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18964
diff
changeset
|
1851 } |
19329
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1852 |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1853 /****************************************************************************/ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1854 /* Scheme-specific functions */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1855 /****************************************************************************/ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1856 |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1857 void |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1858 purple_certificate_display_x509(PurpleCertificate *crt) |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1859 { |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1860 gchar *sha_asc; |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1861 GByteArray *sha_bin; |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1862 gchar *cn; |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1863 time_t activation, expiration; |
19504
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
1864 gchar *activ_str, *expir_str; |
19332
6e0521bb0853
- Fix some g_free()s of string constants that caused crashing
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19331
diff
changeset
|
1865 gchar *secondary; |
19329
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1866 |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1867 /* Pull out the SHA1 checksum */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1868 sha_bin = purple_certificate_get_fingerprint_sha1(crt); |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1869 /* Now decode it for display */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1870 sha_asc = purple_base16_encode_chunked(sha_bin->data, |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1871 sha_bin->len); |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1872 |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1873 /* Get the cert Common Name */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1874 /* TODO: Will break on CA certs */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1875 cn = purple_certificate_get_subject_name(crt); |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1876 |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1877 /* Get the certificate times */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1878 /* TODO: Check the times against localtime */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1879 /* TODO: errorcheck? */ |
19553
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1880 if (!purple_certificate_get_times(crt, &activation, &expiration)) { |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1881 purple_debug_error("certificate", |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1882 "Failed to get certificate times!\n"); |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1883 activation = expiration = 0; |
f36d0d2bf6f2
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19534
diff
changeset
|
1884 } |
19504
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
1885 activ_str = g_strdup(ctime(&activation)); |
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
1886 expir_str = g_strdup(ctime(&expiration)); |
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
1887 |
19329
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1888 /* Make messages */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1889 secondary = g_strdup_printf(_("Common name: %s\n\n" |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1890 "Fingerprint (SHA1): %s\n\n" |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1891 "Activation date: %s\n" |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1892 "Expiration date: %s\n"), |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1893 cn, sha_asc, activ_str, expir_str); |
19504
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
1894 |
19329
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1895 /* Make a semi-pretty display */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1896 purple_notify_info( |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1897 NULL, /* TODO: Find what the handle ought to be */ |
19332
6e0521bb0853
- Fix some g_free()s of string constants that caused crashing
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19331
diff
changeset
|
1898 _("Certificate Information"), |
6e0521bb0853
- Fix some g_free()s of string constants that caused crashing
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19331
diff
changeset
|
1899 "", |
19329
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1900 secondary); |
19504
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
1901 |
19329
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1902 /* Cleanup */ |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1903 g_free(cn); |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1904 g_free(secondary); |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1905 g_free(sha_asc); |
19504
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
1906 g_free(activ_str); |
d5ecaf5bce93
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19497
diff
changeset
|
1907 g_free(expir_str); |
19329
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1908 g_byte_array_free(sha_bin, TRUE); |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1909 } |
e93db0c87b26
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19271
diff
changeset
|
1910 |