Thu, 12 Sep 2013 16:47:08 +0200
Request API: help button support
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1 | /** |
| 19015 | 2 | * @file certificate.c Public-Key Certificate API |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
3 | * @ingroup core |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
4 | */ |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
5 | |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
6 | /* |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
7 | * |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
8 | * purple |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
9 | * |
|
eff6bdd382f3
- 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 |
|
eff6bdd382f3
- 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 |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
12 | * source distribution. |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
13 | * |
|
eff6bdd382f3
- 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 |
|
eff6bdd382f3
- 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 |
|
eff6bdd382f3
- 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 |
|
eff6bdd382f3
- 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. |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
18 | * |
|
eff6bdd382f3
- 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, |
|
eff6bdd382f3
- 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 |
|
eff6bdd382f3
- 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 |
|
eff6bdd382f3
- 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. |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
23 | * |
|
eff6bdd382f3
- 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 |
|
eff6bdd382f3
- 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 |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19827
diff
changeset
|
26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
27 | */ |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
28 | |
|
19668
2071903c58e4
Fix the win32 build for the cert SoC branch merge.
Daniel Atallah <datallah@pidgin.im>
parents:
19500
diff
changeset
|
29 | #include "internal.h" |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
30 | #include "certificate.h" |
|
19688
7eddbc94521c
(Un)Register the pools with DBus to avoid a runtime fit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19678
diff
changeset
|
31 | #include "dbus-maybe.h" |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
32 | #include "debug.h" |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
33 | #include "request.h" |
|
18894
1a00d2309d39
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18818
diff
changeset
|
34 | #include "signals.h" |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
35 | #include "util.h" |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
36 | |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
37 | /** List holding pointers to all registered certificate schemes */ |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
38 | static GList *cert_schemes = NULL; |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
39 | /** List of registered Verifiers */ |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
40 | static GList *cert_verifiers = NULL; |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
41 | /** List of registered Pools */ |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
42 | static GList *cert_pools = NULL; |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
43 | |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
44 | static const gchar * |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
45 | invalidity_reason_to_string(PurpleCertificateVerificationStatus flag) |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
46 | { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
47 | switch (flag) { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
48 | case PURPLE_CERTIFICATE_SELF_SIGNED: |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
49 | return _("The certificate is self-signed and cannot be " |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
50 | "automatically checked."); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
51 | break; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
52 | case PURPLE_CERTIFICATE_CA_UNKNOWN: |
|
28653
f88a1253ed92
Some wordsmithing on this message from Y S Landro, Richard, William, and Kevin (on the translators m-l).
Paul Aurich <darkrain42@pidgin.im>
parents:
28528
diff
changeset
|
53 | return _("The certificate is not trusted because no certificate " |
|
f88a1253ed92
Some wordsmithing on this message from Y S Landro, Richard, William, and Kevin (on the translators m-l).
Paul Aurich <darkrain42@pidgin.im>
parents:
28528
diff
changeset
|
54 | "that can verify it is currently trusted."); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
55 | break; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
56 | case PURPLE_CERTIFICATE_NOT_ACTIVATED: |
|
30472
61a484e29e6e
certificate: Add helpful text to the 'not yet active' message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29982
diff
changeset
|
57 | return _("The certificate is not valid yet. Check that your " |
|
61a484e29e6e
certificate: Add helpful text to the 'not yet active' message.
Paul Aurich <darkrain42@pidgin.im>
parents:
29982
diff
changeset
|
58 | "computer's date and time are accurate."); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
59 | break; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
60 | case PURPLE_CERTIFICATE_EXPIRED: |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
61 | return _("The certificate has expired and should not be " |
|
30815
f771b27caa6b
cert: Tell users to check their computer's date/time for expired certs, too
Paul Aurich <darkrain42@pidgin.im>
parents:
30472
diff
changeset
|
62 | "considered valid. Check that your computer's date " |
|
f771b27caa6b
cert: Tell users to check their computer's date/time for expired certs, too
Paul Aurich <darkrain42@pidgin.im>
parents:
30472
diff
changeset
|
63 | "and time are accurate."); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
64 | break; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
65 | case PURPLE_CERTIFICATE_NAME_MISMATCH: |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
66 | /* Translators: "domain" refers to a DNS domain (e.g. talk.google.com) */ |
|
28337
f3bae8c31997
String change feedback from Stu.
Paul Aurich <darkrain42@pidgin.im>
parents:
28332
diff
changeset
|
67 | return _("The certificate presented is not issued to this domain."); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
68 | break; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
69 | case PURPLE_CERTIFICATE_NO_CA_POOL: |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
70 | return _("You have no database of root certificates, so " |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
71 | "this certificate cannot be validated."); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
72 | break; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
73 | case PURPLE_CERTIFICATE_INVALID_CHAIN: |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
74 | return _("The certificate chain presented is invalid."); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
75 | break; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
76 | case PURPLE_CERTIFICATE_REVOKED: |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
77 | return _("The certificate has been revoked."); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
78 | break; |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
79 | case PURPLE_CERTIFICATE_REJECTED: |
|
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
80 | return _("The certificate was rejected by the user."); |
|
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
81 | break; |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
82 | case PURPLE_CERTIFICATE_UNKNOWN_ERROR: |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
83 | default: |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
84 | return _("An unknown certificate error occurred."); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
85 | break; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
86 | } |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
87 | } |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
88 | |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
89 | void |
|
18462
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
90 | purple_certificate_verify (PurpleCertificateVerifier *verifier, |
|
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
91 | const gchar *subject_name, GList *cert_chain, |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
92 | PurpleCertificateVerifiedCallback cb, |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
93 | gpointer cb_data) |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
94 | { |
|
18462
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
95 | PurpleCertificateVerificationRequest *vrq; |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
96 | PurpleCertificateScheme *scheme; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
97 | |
|
18462
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
98 | g_return_if_fail(subject_name != NULL); |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
99 | /* If you don't have a cert to check, why are you requesting that it |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
100 | be verified? */ |
|
18462
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
101 | g_return_if_fail(cert_chain != NULL); |
|
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
102 | g_return_if_fail(cb != NULL); |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
103 | |
|
18462
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
104 | /* Look up the CertificateScheme */ |
|
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
105 | scheme = purple_certificate_find_scheme(verifier->scheme_name); |
|
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
106 | g_return_if_fail(scheme); |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
107 | |
|
18463
20cf7daafb13
- purple_certificate_verify attempts to check that the cert chain is of
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18462
diff
changeset
|
108 | /* Check that at least the first cert in the chain matches the |
|
20cf7daafb13
- purple_certificate_verify attempts to check that the cert chain is of
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18462
diff
changeset
|
109 | Verifier scheme */ |
|
18479
a38ca6794f6f
- Fixed an inverted assertion
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18477
diff
changeset
|
110 | g_return_if_fail(scheme == |
|
18463
20cf7daafb13
- purple_certificate_verify attempts to check that the cert chain is of
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18462
diff
changeset
|
111 | ((PurpleCertificate *) (cert_chain->data))->scheme); |
|
20cf7daafb13
- purple_certificate_verify attempts to check that the cert chain is of
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18462
diff
changeset
|
112 | |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
113 | /* Construct and fill in the request fields */ |
|
18469
675afaf5559f
- Use g_new0 instead of g_new
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18467
diff
changeset
|
114 | vrq = g_new0(PurpleCertificateVerificationRequest, 1); |
|
18462
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
115 | vrq->verifier = verifier; |
|
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
116 | vrq->scheme = scheme; |
|
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
117 | vrq->subject_name = g_strdup(subject_name); |
|
18656
02c822b398d2
- purple_certificate_verify no longer takes possession of the
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18655
diff
changeset
|
118 | vrq->cert_chain = purple_certificate_copy_list(cert_chain); |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
119 | vrq->cb = cb; |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
120 | vrq->cb_data = cb_data; |
|
18462
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
121 | |
|
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
122 | /* Initiate verification */ |
|
2c6d71addbdb
- purple_certificate_verify now takes a Verifier argument, creates its
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18461
diff
changeset
|
123 | (verifier->start_verification)(vrq); |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
124 | } |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
125 | |
|
18466
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
126 | void |
|
19028
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
127 | purple_certificate_verify_complete(PurpleCertificateVerificationRequest *vrq, |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
128 | PurpleCertificateVerificationStatus st) |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
129 | { |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
130 | PurpleCertificateVerifier *vr; |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
131 | |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
132 | g_return_if_fail(vrq); |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
133 | |
|
20832
3298116f3281
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20831
diff
changeset
|
134 | if (st == PURPLE_CERTIFICATE_VALID) { |
|
3298116f3281
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20831
diff
changeset
|
135 | purple_debug_info("certificate", |
|
3298116f3281
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20831
diff
changeset
|
136 | "Successfully verified certificate for %s\n", |
|
3298116f3281
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20831
diff
changeset
|
137 | vrq->subject_name); |
|
3298116f3281
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20831
diff
changeset
|
138 | } else { |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
25905
diff
changeset
|
139 | purple_debug_error("certificate", |
|
20832
3298116f3281
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20831
diff
changeset
|
140 | "Failed to verify certificate for %s\n", |
|
3298116f3281
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20831
diff
changeset
|
141 | vrq->subject_name); |
|
3298116f3281
- Debugging babble in purple_verify_complete to tell final verification
William Ehlhardt <williamehlhardt@gmail.com>
parents:
20831
diff
changeset
|
142 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
143 | |
|
19028
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
144 | /* Pass the results on to the request's callback */ |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
145 | (vrq->cb)(st, vrq->cb_data); |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
146 | |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
147 | /* And now to eliminate the request */ |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
148 | /* Fetch the Verifier responsible... */ |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
149 | vr = vrq->verifier; |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
150 | /* ...and order it to KILL */ |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
151 | (vr->destroy_request)(vrq); |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
152 | |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
153 | /* Now the internals have been cleaned up, so clean up the libpurple- |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
154 | created elements */ |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
155 | g_free(vrq->subject_name); |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
156 | purple_certificate_destroy_list(vrq->cert_chain); |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
157 | |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
158 | /* A structure born |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
159 | * to much ado |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
160 | * and with so much within. |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
161 | * It reaches now |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
162 | * its quiet end. */ |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
163 | g_free(vrq); |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
164 | } |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
165 | |
|
1c28409e9c5f
- Add verify_complete, which should deprecate verify_destroy
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19026
diff
changeset
|
166 | |
|
18653
ac29c2efe90e
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18649
diff
changeset
|
167 | PurpleCertificate * |
|
ac29c2efe90e
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18649
diff
changeset
|
168 | purple_certificate_copy(PurpleCertificate *crt) |
|
ac29c2efe90e
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18649
diff
changeset
|
169 | { |
|
ac29c2efe90e
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18649
diff
changeset
|
170 | g_return_val_if_fail(crt, NULL); |
|
ac29c2efe90e
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18649
diff
changeset
|
171 | g_return_val_if_fail(crt->scheme, NULL); |
|
ac29c2efe90e
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18649
diff
changeset
|
172 | g_return_val_if_fail(crt->scheme->copy_certificate, NULL); |
|
ac29c2efe90e
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18649
diff
changeset
|
173 | |
|
ac29c2efe90e
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18649
diff
changeset
|
174 | return (crt->scheme->copy_certificate)(crt); |
|
ac29c2efe90e
- Add purple_certificate_copy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18649
diff
changeset
|
175 | } |
|
18467
6bd91f3acf84
- Add purple_certificate_verify_destroy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18466
diff
changeset
|
176 | |
|
18655
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
177 | GList * |
|
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
178 | purple_certificate_copy_list(GList *crt_list) |
|
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
179 | { |
|
24488
9b4d7aa767a2
Fix a printf("%s", NULL). Fixes #7289.
Daniel Atallah <datallah@pidgin.im>
parents:
24182
diff
changeset
|
180 | GList *new_l, *l; |
|
18655
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
181 | |
|
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
182 | /* First, make a shallow copy of the list */ |
|
24488
9b4d7aa767a2
Fix a printf("%s", NULL). Fixes #7289.
Daniel Atallah <datallah@pidgin.im>
parents:
24182
diff
changeset
|
183 | new_l = g_list_copy(crt_list); |
|
18655
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
184 | |
|
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
185 | /* Now go through and actually duplicate each certificate */ |
|
24488
9b4d7aa767a2
Fix a printf("%s", NULL). Fixes #7289.
Daniel Atallah <datallah@pidgin.im>
parents:
24182
diff
changeset
|
186 | for (l = new_l; l; l = l->next) { |
|
18655
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
187 | l->data = purple_certificate_copy(l->data); |
|
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
188 | } |
|
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
189 | |
|
24488
9b4d7aa767a2
Fix a printf("%s", NULL). Fixes #7289.
Daniel Atallah <datallah@pidgin.im>
parents:
24182
diff
changeset
|
190 | return new_l; |
|
18655
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
191 | } |
|
43b99fe59f54
- Add purple_certificate_copy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18653
diff
changeset
|
192 | |
|
18467
6bd91f3acf84
- Add purple_certificate_verify_destroy and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18466
diff
changeset
|
193 | void |
|
18466
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
194 | purple_certificate_destroy (PurpleCertificate *crt) |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
195 | { |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
196 | PurpleCertificateScheme *scheme; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
197 | |
|
18466
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
198 | if (NULL == crt) return; |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
199 | |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
200 | scheme = crt->scheme; |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
201 | |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
202 | (scheme->destroy_certificate)(crt); |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
203 | } |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
204 | |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
205 | void |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
206 | purple_certificate_destroy_list (GList * crt_list) |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
207 | { |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
208 | PurpleCertificate *crt; |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
209 | GList *l; |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
210 | |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
211 | for (l=crt_list; l; l = l->next) { |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
212 | crt = (PurpleCertificate *) l->data; |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
213 | purple_certificate_destroy(crt); |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
214 | } |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
215 | |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
216 | g_list_free(crt_list); |
|
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
217 | } |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
218 | |
|
19016
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
219 | gboolean |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
220 | purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer) |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
221 | { |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
222 | PurpleCertificateScheme *scheme; |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
223 | |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
224 | g_return_val_if_fail(crt, FALSE); |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
225 | g_return_val_if_fail(issuer, FALSE); |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
226 | |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
227 | scheme = crt->scheme; |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
228 | g_return_val_if_fail(scheme, FALSE); |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
229 | /* We can't compare two certs of unrelated schemes, obviously */ |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
230 | g_return_val_if_fail(issuer->scheme == scheme, FALSE); |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
231 | |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
232 | return (scheme->signed_by)(crt, issuer); |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
233 | } |
|
3cf632c31eb3
- Add purple_certificate_signed_by
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19015
diff
changeset
|
234 | |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
235 | gboolean |
|
32590
65bb6a842cdc
Remove the old deprecated purple_certificate_check_signature_chain.
Andrew Victor <andrew.victor@mxit.com>
parents:
31868
diff
changeset
|
236 | purple_certificate_check_signature_chain(GList *chain, |
|
27936
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
237 | PurpleCertificate **failing) |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
238 | { |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
239 | GList *cur; |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
240 | PurpleCertificate *crt, *issuer; |
|
19021
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
241 | gchar *uid; |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
242 | time_t now; |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
243 | gint64 activation, expiration; |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
244 | gboolean ret; |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
245 | |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
246 | g_return_val_if_fail(chain, FALSE); |
|
19021
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
247 | |
|
27936
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
248 | if (failing) |
|
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
249 | *failing = NULL; |
|
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
250 | |
|
19021
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
251 | uid = purple_certificate_get_unique_id((PurpleCertificate *) chain->data); |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
252 | purple_debug_info("certificate", |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
253 | "Checking signature chain for uid=%s\n", |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
254 | uid); |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
255 | g_free(uid); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
256 | |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
257 | /* If this is a single-certificate chain, say that it is valid */ |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
258 | if (chain->next == NULL) { |
|
19021
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
259 | purple_debug_info("certificate", |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
260 | "...Singleton. We'll say it's valid.\n"); |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
261 | return TRUE; |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
262 | } |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
263 | |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
264 | now = time(NULL); |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
265 | |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
266 | /* Load crt with the first certificate */ |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
267 | crt = (PurpleCertificate *)(chain->data); |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
268 | /* And start with the second certificate in the chain */ |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
269 | for ( cur = chain->next; cur; cur = cur->next ) { |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
270 | |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
271 | issuer = (PurpleCertificate *)(cur->data); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
272 | |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
273 | uid = purple_certificate_get_unique_id(issuer); |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
274 | |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
275 | ret = purple_certificate_get_times(issuer, &activation, &expiration); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31155
diff
changeset
|
276 | if (!ret || now < activation || now > expiration) { |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
277 | if (!ret) |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
278 | purple_debug_error("certificate", |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
279 | "...Failed to get validity times for certificate %s\n" |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
280 | "Chain is INVALID\n", uid); |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
281 | else if (now > expiration) { |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
282 | #if GLIB_CHECK_VERSION(2,26,0) |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
283 | GDateTime *exp_dt = g_date_time_new_from_unix_local(expiration); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
284 | gchar *expir_str = g_date_time_format(exp_dt, "%c"); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
285 | g_date_time_unref(exp_dt); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
286 | #else |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
287 | gchar *expir_str = g_strdup(ctime(&expiration)); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
288 | #endif |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
289 | purple_debug_error("certificate", |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
290 | "...Issuer %s expired at %s\nChain is INVALID\n", |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
291 | uid, expir_str); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
292 | g_free(expir_str); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
293 | } else { |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
294 | #if GLIB_CHECK_VERSION(2,26,0) |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
295 | GDateTime *act_dt = g_date_time_new_from_unix_local(activation); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
296 | gchar *activ_str = g_date_time_format(act_dt, "%c"); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
297 | g_date_time_unref(act_dt); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
298 | #else |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
299 | gchar *activ_str = g_strdup(ctime(&activation)); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
300 | #endif |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
301 | purple_debug_error("certificate", |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
302 | "...Not-yet-activated issuer %s will be valid at %s\n" |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
303 | "Chain is INVALID\n", uid, activ_str); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
304 | g_free(activ_str); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
305 | } |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
306 | |
|
27936
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
307 | if (failing) |
|
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
308 | *failing = crt; |
|
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
309 | |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
310 | g_free(uid); |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
311 | return FALSE; |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
312 | } |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
313 | |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
314 | /* Check the signature for this link */ |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
315 | if (! purple_certificate_signed_by(crt, issuer) ) { |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
25905
diff
changeset
|
316 | purple_debug_error("certificate", |
|
19021
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
317 | "...Bad or missing signature by %s\nChain is INVALID\n", |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
318 | uid); |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
319 | g_free(uid); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
320 | |
|
27936
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
321 | if (failing) |
|
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
322 | *failing = crt; |
|
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
323 | |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
324 | return FALSE; |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
325 | } |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
326 | |
|
19021
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
327 | purple_debug_info("certificate", |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
328 | "...Good signature by %s\n", |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
329 | uid); |
|
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
330 | g_free(uid); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
331 | |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
332 | /* The issuer is now the next crt whose signature is to be |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
333 | checked */ |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
334 | crt = issuer; |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
335 | } |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
336 | |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
337 | /* If control reaches this point, the chain is valid */ |
|
19021
a51771bf3d26
- Add debugging babble to check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19020
diff
changeset
|
338 | purple_debug_info("certificate", "Chain is VALID\n"); |
|
19017
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
339 | return TRUE; |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
340 | } |
|
d89f7930272f
- Add purple_certificate_check_signature_chain
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19016
diff
changeset
|
341 | |
|
18577
7b4c95fb042d
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18576
diff
changeset
|
342 | PurpleCertificate * |
|
18578
95080ca9610a
- Fixed naming issues in previous revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18577
diff
changeset
|
343 | purple_certificate_import(PurpleCertificateScheme *scheme, const gchar *filename) |
|
18577
7b4c95fb042d
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18576
diff
changeset
|
344 | { |
|
7b4c95fb042d
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18576
diff
changeset
|
345 | g_return_val_if_fail(scheme, NULL); |
|
7b4c95fb042d
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18576
diff
changeset
|
346 | g_return_val_if_fail(scheme->import_certificate, NULL); |
|
7b4c95fb042d
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18576
diff
changeset
|
347 | g_return_val_if_fail(filename, NULL); |
|
7b4c95fb042d
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18576
diff
changeset
|
348 | |
|
7b4c95fb042d
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18576
diff
changeset
|
349 | return (scheme->import_certificate)(filename); |
|
7b4c95fb042d
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18576
diff
changeset
|
350 | } |
|
7b4c95fb042d
- Add purple_certificate_import
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18576
diff
changeset
|
351 | |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
352 | GSList * |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
353 | purple_certificates_import(PurpleCertificateScheme *scheme, const gchar *filename) |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
354 | { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
355 | g_return_val_if_fail(scheme, NULL); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
356 | g_return_val_if_fail(scheme->import_certificates, NULL); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
357 | g_return_val_if_fail(filename, NULL); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
358 | |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
359 | return (scheme->import_certificates)(filename); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
360 | } |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
361 | |
|
18496
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
362 | gboolean |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
363 | purple_certificate_export(const gchar *filename, PurpleCertificate *crt) |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
364 | { |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
365 | PurpleCertificateScheme *scheme; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
366 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
367 | g_return_val_if_fail(filename, FALSE); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
368 | g_return_val_if_fail(crt, FALSE); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
369 | g_return_val_if_fail(crt->scheme, FALSE); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
370 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
371 | scheme = crt->scheme; |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
372 | g_return_val_if_fail(scheme->export_certificate, FALSE); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
373 | |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
374 | return (scheme->export_certificate)(filename, crt); |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
375 | } |
|
3bb8e716482e
- Add purple_certificate_export and associated libpurple stuff
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18495
diff
changeset
|
376 | |
|
27934
34b573592eb7
A better solution for verifying certificate chains with NSS 3.12.3.
Paul Aurich <darkrain42@pidgin.im>
parents:
27925
diff
changeset
|
377 | static gboolean |
|
34b573592eb7
A better solution for verifying certificate chains with NSS 3.12.3.
Paul Aurich <darkrain42@pidgin.im>
parents:
27925
diff
changeset
|
378 | byte_arrays_equal(const GByteArray *array1, const GByteArray *array2) |
|
34b573592eb7
A better solution for verifying certificate chains with NSS 3.12.3.
Paul Aurich <darkrain42@pidgin.im>
parents:
27925
diff
changeset
|
379 | { |
|
34b573592eb7
A better solution for verifying certificate chains with NSS 3.12.3.
Paul Aurich <darkrain42@pidgin.im>
parents:
27925
diff
changeset
|
380 | g_return_val_if_fail(array1 != NULL, FALSE); |
|
34b573592eb7
A better solution for verifying certificate chains with NSS 3.12.3.
Paul Aurich <darkrain42@pidgin.im>
parents:
27925
diff
changeset
|
381 | g_return_val_if_fail(array2 != NULL, FALSE); |
|
34b573592eb7
A better solution for verifying certificate chains with NSS 3.12.3.
Paul Aurich <darkrain42@pidgin.im>
parents:
27925
diff
changeset
|
382 | |
|
34b573592eb7
A better solution for verifying certificate chains with NSS 3.12.3.
Paul Aurich <darkrain42@pidgin.im>
parents:
27925
diff
changeset
|
383 | return (array1->len == array2->len) && |
|
34b573592eb7
A better solution for verifying certificate chains with NSS 3.12.3.
Paul Aurich <darkrain42@pidgin.im>
parents:
27925
diff
changeset
|
384 | (0 == memcmp(array1->data, array2->data, array1->len)); |
|
34b573592eb7
A better solution for verifying certificate chains with NSS 3.12.3.
Paul Aurich <darkrain42@pidgin.im>
parents:
27925
diff
changeset
|
385 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31155
diff
changeset
|
386 | |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
387 | GByteArray * |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
388 | purple_certificate_get_fingerprint_sha1(PurpleCertificate *crt) |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
389 | { |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
390 | PurpleCertificateScheme *scheme; |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
391 | GByteArray *fpr; |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
392 | |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
393 | g_return_val_if_fail(crt, NULL); |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
394 | g_return_val_if_fail(crt->scheme, NULL); |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
395 | |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
396 | scheme = crt->scheme; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
397 | |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
398 | g_return_val_if_fail(scheme->get_fingerprint_sha1, NULL); |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
399 | |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
400 | fpr = (scheme->get_fingerprint_sha1)(crt); |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
401 | |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
402 | return fpr; |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
403 | } |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
404 | |
|
18481
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
405 | gchar * |
|
19020
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
406 | purple_certificate_get_unique_id(PurpleCertificate *crt) |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
407 | { |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
408 | g_return_val_if_fail(crt, NULL); |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
409 | g_return_val_if_fail(crt->scheme, NULL); |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
410 | g_return_val_if_fail(crt->scheme->get_unique_id, NULL); |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
411 | |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
412 | return (crt->scheme->get_unique_id)(crt); |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
413 | } |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
414 | |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
415 | gchar * |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
416 | purple_certificate_get_issuer_unique_id(PurpleCertificate *crt) |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
417 | { |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
418 | g_return_val_if_fail(crt, NULL); |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
419 | g_return_val_if_fail(crt->scheme, NULL); |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
420 | g_return_val_if_fail(crt->scheme->get_issuer_unique_id, NULL); |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
421 | |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
422 | return (crt->scheme->get_issuer_unique_id)(crt); |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
423 | } |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
424 | |
|
a9af8402bb04
- Expose get_unique_id and get_issuer_unique_id through libpurple functions
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19018
diff
changeset
|
425 | gchar * |
|
18481
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
426 | purple_certificate_get_subject_name(PurpleCertificate *crt) |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
427 | { |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
428 | PurpleCertificateScheme *scheme; |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
429 | gchar *subject_name; |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
430 | |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
431 | g_return_val_if_fail(crt, NULL); |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
432 | g_return_val_if_fail(crt->scheme, NULL); |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
433 | |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
434 | scheme = crt->scheme; |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
435 | |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
436 | g_return_val_if_fail(scheme->get_subject_name, NULL); |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
437 | |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
438 | subject_name = (scheme->get_subject_name)(crt); |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
439 | |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
440 | return subject_name; |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
441 | } |
|
d220d85caaf1
- Add purple_certificate_get_subject_name and associated libpurple
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18479
diff
changeset
|
442 | |
|
18643
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
443 | gboolean |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
444 | purple_certificate_check_subject_name(PurpleCertificate *crt, const gchar *name) |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
445 | { |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
446 | PurpleCertificateScheme *scheme; |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
447 | |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
448 | g_return_val_if_fail(crt, FALSE); |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
449 | g_return_val_if_fail(crt->scheme, FALSE); |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
450 | g_return_val_if_fail(name, FALSE); |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
451 | |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
452 | scheme = crt->scheme; |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
453 | |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
454 | g_return_val_if_fail(scheme->check_subject_name, FALSE); |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
455 | |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
456 | return (scheme->check_subject_name)(crt, name); |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
457 | } |
|
a6a86ac3c219
- Add certificate_check_subject_name and associated machinery
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18590
diff
changeset
|
458 | |
|
18647
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
459 | gboolean |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
460 | purple_certificate_get_times(PurpleCertificate *crt, gint64 *activation, gint64 *expiration) |
|
18647
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
461 | { |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
462 | PurpleCertificateScheme *scheme; |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
463 | |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
464 | g_return_val_if_fail(crt, FALSE); |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
465 | |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
466 | scheme = crt->scheme; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
467 | |
|
18647
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
468 | g_return_val_if_fail(scheme, FALSE); |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
469 | |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
470 | /* If both provided references are NULL, what are you doing calling |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
471 | this? */ |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
472 | g_return_val_if_fail( (activation != NULL) || (expiration != NULL), FALSE); |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
473 | |
|
19007
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19003
diff
changeset
|
474 | /* Throw the request on down to the certscheme */ |
|
f3c3ddf37812
- Change the internal structure of activation/expiration times to match
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19003
diff
changeset
|
475 | return (scheme->get_times)(crt, activation, expiration); |
|
18647
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
476 | } |
|
45240511f4eb
- Add expiration/activation functions for Certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18645
diff
changeset
|
477 | |
|
32767
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
478 | GByteArray * |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
479 | purple_certificate_get_der_data(PurpleCertificate *crt) |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
480 | { |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
481 | PurpleCertificateScheme *scheme; |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
482 | GByteArray *data; |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
483 | |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
484 | g_return_val_if_fail(crt, NULL); |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
485 | g_return_val_if_fail(crt->scheme, NULL); |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
486 | |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
487 | scheme = crt->scheme; |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
488 | |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
489 | g_return_val_if_fail(scheme->get_der_data, NULL); |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
490 | |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
491 | data = (scheme->get_der_data)(crt); |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
492 | |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
493 | return data; |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
494 | } |
|
581cd5f30198
Add a function for retrieving the raw DER representation of a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32590
diff
changeset
|
495 | |
|
18573
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
496 | gchar * |
|
32885
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
497 | purple_certificate_get_display_string(PurpleCertificate *crt) |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
498 | { |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
499 | PurpleCertificateScheme *scheme; |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
500 | gchar *str; |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
501 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
502 | g_return_val_if_fail(crt, NULL); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
503 | g_return_val_if_fail(crt->scheme, NULL); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
504 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
505 | scheme = crt->scheme; |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
506 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
507 | g_return_val_if_fail(scheme->get_display_string, NULL); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
508 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
509 | str = (scheme->get_display_string)(crt); |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
510 | |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
511 | return str; |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
512 | } |
|
d65261e7426e
Add a function for converting a PurpleCertificate to a string
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32767
diff
changeset
|
513 | |
|
18573
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
514 | gchar * |
|
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
515 | purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id) |
|
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
516 | { |
|
18645
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
517 | gchar *path; |
|
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
518 | gchar *esc_scheme_name, *esc_name, *esc_id; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
519 | |
|
18573
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
520 | g_return_val_if_fail(pool, NULL); |
|
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
521 | g_return_val_if_fail(pool->scheme_name, NULL); |
|
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
522 | g_return_val_if_fail(pool->name, NULL); |
|
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
523 | |
|
18645
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
524 | /* Escape all the elements for filesystem-friendliness */ |
|
33769
96f89e35d24d
Fix various "Dereference before null check" issues
Daniel Atallah <datallah@pidgin.im>
parents:
31377
diff
changeset
|
525 | esc_scheme_name = g_strdup(purple_escape_filename(pool->scheme_name)); |
|
96f89e35d24d
Fix various "Dereference before null check" issues
Daniel Atallah <datallah@pidgin.im>
parents:
31377
diff
changeset
|
526 | esc_name = g_strdup(purple_escape_filename(pool->name)); |
|
18817
d4d89568fab6
- Handle NULLs given to certificate_pool_mkpath without causing errors
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18662
diff
changeset
|
527 | esc_id = id ? g_strdup(purple_escape_filename(id)) : NULL; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
528 | |
|
18573
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
529 | path = g_build_filename(purple_user_dir(), |
|
18575
24299c91b963
- Correct the certstore folder paths
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18574
diff
changeset
|
530 | "certificates", /* TODO: constantize this? */ |
|
18645
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
531 | esc_scheme_name, |
|
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
532 | esc_name, |
|
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
533 | esc_id, |
|
18573
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
534 | NULL); |
|
18644
ac67b1ff08c4
- pool_mkpath now runs purple_escape_filename on its return value
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18643
diff
changeset
|
535 | |
|
18645
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
536 | g_free(esc_scheme_name); |
|
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
537 | g_free(esc_name); |
|
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
538 | g_free(esc_id); |
|
805a3f4b259d
- Fix overzealous escaping cause by ancestor revision
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18644
diff
changeset
|
539 | return path; |
|
18573
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
540 | } |
|
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
541 | |
|
18584
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
542 | gboolean |
|
18818
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
543 | purple_certificate_pool_usable(PurpleCertificatePool *pool) |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
544 | { |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
545 | g_return_val_if_fail(pool, FALSE); |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
546 | g_return_val_if_fail(pool->scheme_name, FALSE); |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
547 | |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
548 | /* Check that the pool's scheme is loaded */ |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
549 | if (purple_certificate_find_scheme(pool->scheme_name) == NULL) { |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
550 | return FALSE; |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
551 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
552 | |
|
18818
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
553 | return TRUE; |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
554 | } |
|
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
555 | |
|
19000
ec4a9c38e415
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18900
diff
changeset
|
556 | PurpleCertificateScheme * |
|
ec4a9c38e415
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18900
diff
changeset
|
557 | purple_certificate_pool_get_scheme(PurpleCertificatePool *pool) |
|
ec4a9c38e415
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18900
diff
changeset
|
558 | { |
|
ec4a9c38e415
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18900
diff
changeset
|
559 | g_return_val_if_fail(pool, NULL); |
|
ec4a9c38e415
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18900
diff
changeset
|
560 | g_return_val_if_fail(pool->scheme_name, NULL); |
|
ec4a9c38e415
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18900
diff
changeset
|
561 | |
|
ec4a9c38e415
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18900
diff
changeset
|
562 | return purple_certificate_find_scheme(pool->scheme_name); |
|
ec4a9c38e415
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18900
diff
changeset
|
563 | } |
|
ec4a9c38e415
- Add purple_certificate_pool_get_scheme helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18900
diff
changeset
|
564 | |
|
18818
6460aa4cfa41
- Add purple_certificate_pool_usable to check whether a pool's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18817
diff
changeset
|
565 | gboolean |
|
18584
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
566 | purple_certificate_pool_contains(PurpleCertificatePool *pool, const gchar *id) |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
567 | { |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
568 | g_return_val_if_fail(pool, FALSE); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
569 | g_return_val_if_fail(id, FALSE); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
570 | g_return_val_if_fail(pool->cert_in_pool, FALSE); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
571 | |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
572 | return (pool->cert_in_pool)(id); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
573 | } |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
574 | |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
575 | PurpleCertificate * |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
576 | purple_certificate_pool_retrieve(PurpleCertificatePool *pool, const gchar *id) |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
577 | { |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
578 | g_return_val_if_fail(pool, NULL); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
579 | g_return_val_if_fail(id, NULL); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
580 | g_return_val_if_fail(pool->get_cert, NULL); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
581 | |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
582 | return (pool->get_cert)(id); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
583 | } |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
584 | |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
585 | gboolean |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
586 | purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, PurpleCertificate *crt) |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
587 | { |
|
18896
70742468a820
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18894
diff
changeset
|
588 | gboolean ret = FALSE; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
589 | |
|
18584
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
590 | g_return_val_if_fail(pool, FALSE); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
591 | g_return_val_if_fail(id, FALSE); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
592 | g_return_val_if_fail(pool->put_cert, FALSE); |
|
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
593 | |
|
18585
5a9738565416
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18584
diff
changeset
|
594 | /* Whether crt->scheme matches find_scheme(pool->scheme_name) is not |
|
5a9738565416
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18584
diff
changeset
|
595 | relevant... I think... */ |
|
5a9738565416
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18584
diff
changeset
|
596 | g_return_val_if_fail( |
|
5a9738565416
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18584
diff
changeset
|
597 | g_ascii_strcasecmp(pool->scheme_name, crt->scheme->name) == 0, |
|
5a9738565416
- Do some weak checking to ensure that you don't attempt to store a
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18584
diff
changeset
|
598 | FALSE); |
|
18584
d4410000050f
- Add pool retrieve, contains, and store functions to certificate API
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18582
diff
changeset
|
599 | |
|
18896
70742468a820
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18894
diff
changeset
|
600 | ret = (pool->put_cert)(id, crt); |
|
70742468a820
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18894
diff
changeset
|
601 | |
|
18900
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
602 | /* Signal that the certificate was stored if success*/ |
|
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
603 | if (ret) { |
|
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
604 | purple_signal_emit(pool, "certificate-stored", |
|
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
605 | pool, id); |
|
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
606 | } |
|
18896
70742468a820
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18894
diff
changeset
|
607 | |
|
70742468a820
- Emit certificate-stored signal in purple_certificate_pool_store
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18894
diff
changeset
|
608 | return ret; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
609 | } |
|
18573
c7fd4fbb4339
- Add purple_certificate_pool_mkpath helper function
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18571
diff
changeset
|
610 | |
|
18899
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
611 | gboolean |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
612 | purple_certificate_pool_delete(PurpleCertificatePool *pool, const gchar *id) |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
613 | { |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
614 | gboolean ret = FALSE; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
615 | |
|
18899
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
616 | g_return_val_if_fail(pool, FALSE); |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
617 | g_return_val_if_fail(id, FALSE); |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
618 | g_return_val_if_fail(pool->delete_cert, FALSE); |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
619 | |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
620 | ret = (pool->delete_cert)(id); |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
621 | |
|
18900
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
622 | /* Signal that the certificate was deleted if success */ |
|
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
623 | if (ret) { |
|
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
624 | purple_signal_emit(pool, "certificate-deleted", |
|
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
625 | pool, id); |
|
8107b08ec7ae
- Only emit certificate-stored and certificate-deleted if the operation
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18899
diff
changeset
|
626 | } |
|
18899
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
627 | |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
628 | return ret; |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
629 | } |
|
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
630 | |
|
18661
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
631 | GList * |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
632 | purple_certificate_pool_get_idlist(PurpleCertificatePool *pool) |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
633 | { |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
634 | g_return_val_if_fail(pool, NULL); |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
635 | g_return_val_if_fail(pool->get_idlist, NULL); |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
636 | |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
637 | return (pool->get_idlist)(); |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
638 | } |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
639 | |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
640 | void |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
641 | purple_certificate_pool_destroy_idlist(GList *idlist) |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
642 | { |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
643 | GList *l; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
644 | |
|
18661
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
645 | /* Iterate through and free them strings */ |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
646 | for ( l = idlist; l; l = l->next ) { |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
647 | g_free(l->data); |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
648 | } |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
649 | |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
650 | g_list_free(idlist); |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
651 | } |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
652 | |
|
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
653 | |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
654 | /****************************************************************************/ |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
655 | /* Builtin Verifiers, Pools, etc. */ |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
656 | /****************************************************************************/ |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
657 | |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
658 | static void |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
659 | x509_singleuse_verify_accept_cb(PurpleCertificateVerificationRequest *vrq) |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
660 | { |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
661 | g_return_if_fail(vrq); |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
662 | |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
663 | purple_debug_info("certificate/x509_singleuse", |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
664 | "VRQ on cert from %s accepted\n", |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
665 | vrq->subject_name); |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
666 | |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
667 | purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_VALID); |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
668 | } |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
669 | |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
670 | static void |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
671 | x509_singleuse_verify_reject_cb(PurpleCertificateVerificationRequest *vrq) |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
672 | { |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
673 | g_return_if_fail(vrq); |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
674 | |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
675 | purple_debug_info("certificate/x509_singleuse", |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
676 | "VRQ on cert from %s rejected\n", |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
677 | vrq->subject_name); |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
678 | |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
679 | purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_REJECTED); |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
680 | } |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
681 | |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
682 | static void |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
683 | x509_singleuse_start_verify (PurpleCertificateVerificationRequest *vrq) |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
684 | { |
|
18483
113bfeceaf1b
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18481
diff
changeset
|
685 | gchar *cn; |
|
113bfeceaf1b
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18481
diff
changeset
|
686 | const gchar *cn_match; |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
687 | gchar *primary, *secondary; |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
688 | PurpleCertificate *crt = (PurpleCertificate *)vrq->cert_chain->data; |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
689 | |
|
18483
113bfeceaf1b
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18481
diff
changeset
|
690 | cn = purple_certificate_get_subject_name(crt); |
|
113bfeceaf1b
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18481
diff
changeset
|
691 | |
|
19499
6b9c37c4ca85
- Even more TODO whacking
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19498
diff
changeset
|
692 | if (purple_certificate_check_subject_name(crt, vrq->subject_name)) { |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
693 | cn_match = _("(MATCH)"); |
|
18483
113bfeceaf1b
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18481
diff
changeset
|
694 | } else { |
|
113bfeceaf1b
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18481
diff
changeset
|
695 | cn_match = _("(DOES NOT MATCH)"); |
|
113bfeceaf1b
- x509_singleuse uses the subject_name field...somewhat
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18481
diff
changeset
|
696 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
697 | |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
698 | primary = g_strdup_printf(_("%s has presented the following certificate for just-this-once use:"), vrq->subject_name); |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
699 | secondary = g_strdup_printf(_("Common name: %s %s"), cn, cn_match); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
700 | |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
701 | /* Make a semi-pretty display */ |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
702 | purple_request_certificate( |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
703 | vrq->cb_data, /* TODO: Find what the handle ought to be */ |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
704 | _("Single-use Certificate Verification"), |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
705 | primary, |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
706 | secondary, |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
707 | crt, |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
708 | _("Accept"), G_CALLBACK(x509_singleuse_verify_accept_cb), |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
709 | _("Reject"), G_CALLBACK(x509_singleuse_verify_reject_cb), |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
710 | vrq); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
711 | |
|
29982
e2a8f797a521
A couple more leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29930
diff
changeset
|
712 | g_free(cn); |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
713 | g_free(primary); |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
714 | g_free(secondary); |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
715 | } |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
716 | |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
717 | static void |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
718 | x509_singleuse_destroy_request (PurpleCertificateVerificationRequest *vrq) |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
719 | { |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
720 | /* I don't do anything! */ |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
721 | } |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
722 | |
|
22734
4d1dde18dada
Make x509_singleuse static
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22622
diff
changeset
|
723 | static PurpleCertificateVerifier x509_singleuse = { |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
724 | "x509", /* Scheme name */ |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
725 | "singleuse", /* Verifier name */ |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
726 | x509_singleuse_start_verify, /* start_verification function */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
727 | x509_singleuse_destroy_request, /* Request cleanup operation */ |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
728 | |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
729 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
730 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
731 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
732 | NULL |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
733 | }; |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
734 | |
|
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
735 | |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
736 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
737 | /***** X.509 Certificate Authority pool, keyed by Distinguished Name *****/ |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
738 | /* This is implemented in what may be the most inefficient and bugprone way |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
739 | possible; however, future optimizations should not be difficult. */ |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
740 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
741 | static PurpleCertificatePool x509_ca; |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
742 | |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
743 | /** Holds a key-value pair for quickish certificate lookup */ |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
744 | typedef struct { |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
745 | gchar *dn; |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
746 | PurpleCertificate *crt; |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
747 | } x509_ca_element; |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
748 | |
|
19348
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
749 | static void |
|
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
750 | x509_ca_element_free(x509_ca_element *el) |
|
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
751 | { |
|
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
752 | if (NULL == el) return; |
|
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
753 | |
|
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
754 | g_free(el->dn); |
|
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
755 | purple_certificate_destroy(el->crt); |
|
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
756 | g_free(el); |
|
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
757 | } |
|
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
758 | |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
759 | /** System directory to probe for CA certificates */ |
|
19484
237d66fea269
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19352
diff
changeset
|
760 | /* This is set in the lazy_init function */ |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
761 | static GList *x509_ca_paths = NULL; |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
762 | |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
763 | /** A list of loaded CAs, populated from the above path whenever the lazy_init |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
764 | happens. Contains pointers to x509_ca_elements */ |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
765 | static GList *x509_ca_certs = NULL; |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
766 | |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
767 | /** Used for lazy initialization purposes. */ |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
768 | static gboolean x509_ca_initialized = FALSE; |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
769 | |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
770 | /** Adds a certificate to the in-memory cache, doing nothing else */ |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
771 | static gboolean |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
772 | x509_ca_quiet_put_cert(PurpleCertificate *crt) |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
773 | { |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
774 | x509_ca_element *el; |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
775 | |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
776 | /* lazy_init calls this function, so calling lazy_init here is a |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
777 | Bad Thing */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
778 | |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
779 | g_return_val_if_fail(crt, FALSE); |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
780 | g_return_val_if_fail(crt->scheme, FALSE); |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
781 | /* Make sure that this is some kind of X.509 certificate */ |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
782 | /* TODO: Perhaps just check crt->scheme->name instead? */ |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
783 | g_return_val_if_fail(crt->scheme == purple_certificate_find_scheme(x509_ca.scheme_name), FALSE); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
784 | |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
785 | el = g_new0(x509_ca_element, 1); |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
786 | el->dn = purple_certificate_get_unique_id(crt); |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
787 | el->crt = purple_certificate_copy(crt); |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
788 | x509_ca_certs = g_list_prepend(x509_ca_certs, el); |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
789 | |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
790 | return TRUE; |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
791 | } |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
792 | |
|
19484
237d66fea269
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19352
diff
changeset
|
793 | /* Since the libpurple CertificatePools get registered before plugins are |
|
237d66fea269
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19352
diff
changeset
|
794 | loaded, an X.509 Scheme is generally not available when x509_ca_init is |
|
237d66fea269
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19352
diff
changeset
|
795 | called, but x509_ca requires X.509 operations in order to properly load. |
|
237d66fea269
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19352
diff
changeset
|
796 | |
|
237d66fea269
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19352
diff
changeset
|
797 | To solve this, I present the lazy_init function. It attempts to finish |
|
237d66fea269
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19352
diff
changeset
|
798 | initialization of the Pool, but it usually fails when it is called from |
|
237d66fea269
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19352
diff
changeset
|
799 | x509_ca_init. However, this is OK; initialization is then simply deferred |
|
237d66fea269
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19352
diff
changeset
|
800 | until someone tries to use functions from the pool. */ |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
801 | static gboolean |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
802 | x509_ca_lazy_init(void) |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
803 | { |
|
19035
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
804 | PurpleCertificateScheme *x509; |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
805 | GDir *certdir; |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
806 | const gchar *entry; |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
807 | GPatternSpec *pempat, *crtpat; |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
808 | GList *iter = NULL; |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
809 | GSList *crts = NULL; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
810 | |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
811 | if (x509_ca_initialized) return TRUE; |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
812 | |
|
19035
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
813 | /* Check that X.509 is registered */ |
|
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
814 | x509 = purple_certificate_find_scheme(x509_ca.scheme_name); |
|
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
815 | if ( !x509 ) { |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
25905
diff
changeset
|
816 | purple_debug_warning("certificate/x509/ca", |
|
19035
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
817 | "Lazy init failed because an X.509 Scheme " |
|
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
818 | "is not yet registered. Maybe it will be " |
|
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
819 | "better later.\n"); |
|
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
820 | return FALSE; |
|
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
821 | } |
|
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
822 | |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
823 | /* Use a glob to only read .pem files */ |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
824 | pempat = g_pattern_spec_new("*.pem"); |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
825 | crtpat = g_pattern_spec_new("*.crt"); |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
826 | |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
827 | /* Populate the certificates pool from the search path(s) */ |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
828 | for (iter = x509_ca_paths; iter; iter = iter->next) { |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
829 | certdir = g_dir_open(iter->data, 0, NULL); |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
830 | if (!certdir) { |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22269
diff
changeset
|
831 | purple_debug_error("certificate/x509/ca", "Couldn't open location '%s'\n", (const char *)iter->data); |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
832 | continue; |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
833 | } |
|
19035
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
834 | |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
835 | while ( (entry = g_dir_read_name(certdir)) ) { |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
836 | gchar *fullpath; |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
837 | PurpleCertificate *crt; |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
838 | |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
839 | if (!g_pattern_match_string(pempat, entry) && !g_pattern_match_string(crtpat, entry)) { |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
840 | continue; |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
841 | } |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
842 | |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
843 | fullpath = g_build_filename(iter->data, entry, NULL); |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
844 | |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
845 | /* TODO: Respond to a failure in the following? */ |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
846 | crts = purple_certificates_import(x509, fullpath); |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
847 | |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
848 | while (crts && crts->data) { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
849 | crt = crts->data; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
850 | if (x509_ca_quiet_put_cert(crt)) { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
851 | gchar *name; |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
852 | name = purple_certificate_get_subject_name(crt); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
853 | purple_debug_info("certificate/x509/ca", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
854 | "Loaded %s from %s\n", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
855 | name ? name : "(unknown)", fullpath); |
|
29982
e2a8f797a521
A couple more leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29930
diff
changeset
|
856 | g_free(name); |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
857 | } else { |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
858 | purple_debug_error("certificate/x509/ca", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
859 | "Failed to load certificate from %s\n", |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
860 | fullpath); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
861 | } |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
862 | purple_certificate_destroy(crt); |
|
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
863 | crts = g_slist_delete_link(crts, crts); |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
864 | } |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
865 | |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
866 | g_free(fullpath); |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
867 | } |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
868 | g_dir_close(certdir); |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
869 | } |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
870 | |
|
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
871 | g_pattern_spec_free(pempat); |
|
29930
80f4616de5ce
Implement reading multiple certificates from a single "bundle" of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29390
diff
changeset
|
872 | g_pattern_spec_free(crtpat); |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
873 | |
|
19035
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
874 | purple_debug_info("certificate/x509/ca", |
|
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
875 | "Lazy init completed.\n"); |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
876 | x509_ca_initialized = TRUE; |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
877 | return TRUE; |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
878 | } |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
879 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
880 | static gboolean |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
881 | x509_ca_init(void) |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
882 | { |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
883 | /* Attempt to point at the appropriate system path */ |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
884 | if (NULL == x509_ca_paths) { |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
885 | #ifdef _WIN32 |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
886 | x509_ca_paths = g_list_append(NULL, g_build_filename(DATADIR, |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
887 | "ca-certs", NULL)); |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
888 | #else |
|
23473
df05ffc37ed0
Add a configure option, --with-ssl-certificates to allow packagers to
Richard Laager <rlaager@pidgin.im>
parents:
23178
diff
changeset
|
889 | # ifdef SSL_CERTIFICATES_DIR |
|
24014
9abbc8608b3c
Fix a crash on exit when using --with-system-ssl-certs
Mark Doliner <markdoliner@pidgin.im>
parents:
23473
diff
changeset
|
890 | x509_ca_paths = g_list_append(NULL, g_strdup(SSL_CERTIFICATES_DIR)); |
|
23473
df05ffc37ed0
Add a configure option, --with-ssl-certificates to allow packagers to
Richard Laager <rlaager@pidgin.im>
parents:
23178
diff
changeset
|
891 | # endif |
|
25165
36febee8749c
uncondtionally install some certificates and use them, References #6680.
Ka-Hing Cheung <khc@pidgin.im>
parents:
24488
diff
changeset
|
892 | x509_ca_paths = g_list_append(x509_ca_paths, |
|
36febee8749c
uncondtionally install some certificates and use them, References #6680.
Ka-Hing Cheung <khc@pidgin.im>
parents:
24488
diff
changeset
|
893 | g_build_filename(DATADIR, "purple", "ca-certs", NULL)); |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
894 | #endif |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
895 | } |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
896 | |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
897 | /* Attempt to initialize now, but if it doesn't work, that's OK; |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
898 | it will get done later */ |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
899 | if ( ! x509_ca_lazy_init()) { |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
900 | purple_debug_info("certificate/x509/ca", |
|
19035
523335f1d52b
- x509_ca_lazy_init is more implemented
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19034
diff
changeset
|
901 | "Init failed, probably because a " |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
902 | "dependency is not yet registered. " |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
903 | "It has been deferred to later.\n"); |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
904 | } |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
905 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
906 | return TRUE; |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
907 | } |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
908 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
909 | static void |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
910 | x509_ca_uninit(void) |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
911 | { |
|
19343
08189e9c5de8
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19342
diff
changeset
|
912 | GList *l; |
|
08189e9c5de8
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19342
diff
changeset
|
913 | |
|
08189e9c5de8
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19342
diff
changeset
|
914 | for (l = x509_ca_certs; l; l = l->next) { |
|
08189e9c5de8
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19342
diff
changeset
|
915 | x509_ca_element *el = l->data; |
|
19348
507a3bf4c4d4
- Add a helper function to destroy x509_ca_elements, and use it where
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19347
diff
changeset
|
916 | x509_ca_element_free(el); |
|
19343
08189e9c5de8
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19342
diff
changeset
|
917 | } |
|
08189e9c5de8
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19342
diff
changeset
|
918 | g_list_free(x509_ca_certs); |
|
08189e9c5de8
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19342
diff
changeset
|
919 | x509_ca_certs = NULL; |
|
08189e9c5de8
- Write the uninit function for x509_ca
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19342
diff
changeset
|
920 | x509_ca_initialized = FALSE; |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
921 | g_list_foreach(x509_ca_paths, (GFunc)g_free, NULL); |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
922 | g_list_free(x509_ca_paths); |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
923 | x509_ca_paths = NULL; |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
924 | } |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
925 | |
|
19344
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
926 | /** Look up a ca_element by dn */ |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
927 | static x509_ca_element * |
| 19346 | 928 | x509_ca_locate_cert(GList *lst, const gchar *dn) |
|
19344
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
929 | { |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
930 | GList *cur; |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
931 | |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
932 | for (cur = lst; cur; cur = cur->next) { |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
933 | x509_ca_element *el = cur->data; |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
25275
diff
changeset
|
934 | if (purple_strequal(dn, el->dn)) { |
|
19344
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
935 | return el; |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
936 | } |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
937 | } |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
938 | return NULL; |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
939 | } |
|
66e33c6fe7c3
- Add a function to search the x509_ca internal structures for an id
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19343
diff
changeset
|
940 | |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
941 | static GSList * |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
942 | x509_ca_locate_certs(GList *lst, const gchar *dn) |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
943 | { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
944 | GList *cur; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
945 | GSList *crts = NULL; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
946 | |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
947 | for (cur = lst; cur; cur = cur->next) { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
948 | x509_ca_element *el = cur->data; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
949 | if (purple_strequal(dn, el->dn)) { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
950 | crts = g_slist_prepend(crts, el); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
951 | } |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
952 | } |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
953 | return crts; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
954 | } |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
955 | |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
956 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
957 | static gboolean |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
958 | x509_ca_cert_in_pool(const gchar *id) |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
959 | { |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
960 | g_return_val_if_fail(x509_ca_lazy_init(), FALSE); |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
961 | g_return_val_if_fail(id, FALSE); |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
962 | |
| 19346 | 963 | if (x509_ca_locate_cert(x509_ca_certs, id) != NULL) { |
|
19345
939e2898106f
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19344
diff
changeset
|
964 | return TRUE; |
|
939e2898106f
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19344
diff
changeset
|
965 | } else { |
|
939e2898106f
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19344
diff
changeset
|
966 | return FALSE; |
|
939e2898106f
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19344
diff
changeset
|
967 | } |
|
939e2898106f
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19344
diff
changeset
|
968 | |
|
939e2898106f
- Implement x509_ca cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19344
diff
changeset
|
969 | return FALSE; |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
970 | } |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
971 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
972 | static PurpleCertificate * |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
973 | x509_ca_get_cert(const gchar *id) |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
974 | { |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
975 | PurpleCertificate *crt = NULL; |
|
19347
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
976 | x509_ca_element *el; |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
977 | |
|
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
978 | g_return_val_if_fail(x509_ca_lazy_init(), NULL); |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
979 | g_return_val_if_fail(id, NULL); |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
980 | |
|
19347
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
981 | /* Search the memory-cached pool */ |
|
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
982 | el = x509_ca_locate_cert(x509_ca_certs, id); |
|
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
983 | |
|
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
984 | if (el != NULL) { |
|
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
985 | /* Make a copy of the memcached one for the function caller |
|
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
986 | to play with */ |
|
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
987 | crt = purple_certificate_copy(el->crt); |
|
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
988 | } else { |
|
ec35ba7ac30a
- Implement x509_ca_get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19346
diff
changeset
|
989 | crt = NULL; |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
990 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
991 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
992 | return crt; |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
993 | } |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
994 | |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
995 | static GSList * |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
996 | x509_ca_get_certs(const gchar *id) |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
997 | { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
998 | GSList *crts = NULL, *els = NULL; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
999 | |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1000 | g_return_val_if_fail(x509_ca_lazy_init(), NULL); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1001 | g_return_val_if_fail(id, NULL); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1002 | |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1003 | /* Search the memory-cached pool */ |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1004 | els = x509_ca_locate_certs(x509_ca_certs, id); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1005 | |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1006 | if (els != NULL) { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1007 | GSList *cur; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1008 | /* Make a copy of the memcached ones for the function caller |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1009 | to play with */ |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1010 | for (cur = els; cur; cur = cur->next) { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1011 | x509_ca_element *el = cur->data; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1012 | crts = g_slist_prepend(crts, purple_certificate_copy(el->crt)); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1013 | } |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1014 | g_slist_free(els); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1015 | } |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1016 | |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1017 | return crts; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1018 | } |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1019 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1020 | static gboolean |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1021 | x509_ca_put_cert(const gchar *id, PurpleCertificate *crt) |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1022 | { |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1023 | gboolean ret = FALSE; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1024 | |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
1025 | g_return_val_if_fail(x509_ca_lazy_init(), FALSE); |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1026 | |
|
19036
62025e265d24
- Add a hacked-up method of adding certs to the CA pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19035
diff
changeset
|
1027 | /* TODO: This is a quick way of doing this. At some point the change |
|
62025e265d24
- Add a hacked-up method of adding certs to the CA pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19035
diff
changeset
|
1028 | ought to be flushed to disk somehow. */ |
|
19342
9a4aa6fc93d4
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19036
diff
changeset
|
1029 | ret = x509_ca_quiet_put_cert(crt); |
|
19036
62025e265d24
- Add a hacked-up method of adding certs to the CA pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19035
diff
changeset
|
1030 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1031 | return ret; |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1032 | } |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1033 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1034 | static gboolean |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1035 | x509_ca_delete_cert(const gchar *id) |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1036 | { |
|
19349
747af1d98998
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19348
diff
changeset
|
1037 | x509_ca_element *el; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1038 | |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
1039 | g_return_val_if_fail(x509_ca_lazy_init(), FALSE); |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1040 | g_return_val_if_fail(id, FALSE); |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1041 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1042 | /* Is the id even in the pool? */ |
|
19349
747af1d98998
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19348
diff
changeset
|
1043 | el = x509_ca_locate_cert(x509_ca_certs, id); |
|
747af1d98998
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19348
diff
changeset
|
1044 | if ( el == NULL ) { |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
1045 | purple_debug_warning("certificate/x509/ca", |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1046 | "Id %s wasn't in the pool\n", |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1047 | id); |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1048 | return FALSE; |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1049 | } |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1050 | |
|
19349
747af1d98998
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19348
diff
changeset
|
1051 | /* Unlink it from the memory cache and destroy it */ |
|
747af1d98998
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19348
diff
changeset
|
1052 | x509_ca_certs = g_list_remove(x509_ca_certs, el); |
|
747af1d98998
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19348
diff
changeset
|
1053 | x509_ca_element_free(el); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1054 | |
|
19349
747af1d98998
- Implement x509_ca_delete_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19348
diff
changeset
|
1055 | return TRUE; |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1056 | } |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1057 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1058 | static GList * |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1059 | x509_ca_get_idlist(void) |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1060 | { |
|
19350
847740e5ca57
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19349
diff
changeset
|
1061 | GList *l, *idlist; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1062 | |
|
19034
656cf1384216
In x509_ca pool:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19033
diff
changeset
|
1063 | g_return_val_if_fail(x509_ca_lazy_init(), NULL); |
|
19350
847740e5ca57
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19349
diff
changeset
|
1064 | |
|
847740e5ca57
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19349
diff
changeset
|
1065 | idlist = NULL; |
|
847740e5ca57
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19349
diff
changeset
|
1066 | for (l = x509_ca_certs; l; l = l->next) { |
|
847740e5ca57
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19349
diff
changeset
|
1067 | x509_ca_element *el = l->data; |
|
847740e5ca57
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19349
diff
changeset
|
1068 | idlist = g_list_prepend(idlist, g_strdup(el->dn)); |
|
847740e5ca57
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19349
diff
changeset
|
1069 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1070 | |
|
19350
847740e5ca57
- Implement x509_ca_get_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19349
diff
changeset
|
1071 | return idlist; |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1072 | } |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1073 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1074 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1075 | static PurpleCertificatePool x509_ca = { |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1076 | "x509", /* Scheme name */ |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1077 | "ca", /* Pool name */ |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1078 | N_("Certificate Authorities"),/* User-friendly name */ |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1079 | NULL, /* Internal data */ |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1080 | x509_ca_init, /* init */ |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1081 | x509_ca_uninit, /* uninit */ |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1082 | x509_ca_cert_in_pool, /* Certificate exists? */ |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1083 | x509_ca_get_cert, /* Cert retriever */ |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1084 | x509_ca_put_cert, /* Cert writer */ |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1085 | x509_ca_delete_cert, /* Cert remover */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1086 | x509_ca_get_idlist, /* idlist retriever */ |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1087 | |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1088 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1089 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1090 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1091 | NULL |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1092 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1093 | }; |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1094 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1095 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1096 | |
|
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1097 | /***** Cache of certificates given by TLS/SSL peers *****/ |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1098 | static PurpleCertificatePool x509_tls_peers; |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1099 | |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1100 | static gboolean |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1101 | x509_tls_peers_init(void) |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1102 | { |
|
18574
ee5a638ce111
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18573
diff
changeset
|
1103 | gchar *poolpath; |
|
ee5a638ce111
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18573
diff
changeset
|
1104 | int ret; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1105 | |
|
18574
ee5a638ce111
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18573
diff
changeset
|
1106 | /* Set up key cache here if it isn't already done */ |
|
ee5a638ce111
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18573
diff
changeset
|
1107 | poolpath = purple_certificate_pool_mkpath(&x509_tls_peers, NULL); |
|
ee5a638ce111
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18573
diff
changeset
|
1108 | ret = purple_build_dir(poolpath, 0700); /* Make it this user only */ |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1109 | |
|
27788
135010d3e3a9
Don't fail an assertion and don't return FALSE if we can't create
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1110 | if (ret != 0) |
|
135010d3e3a9
Don't fail an assertion and don't return FALSE if we can't create
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1111 | purple_debug_info("certificate/tls_peers", |
|
135010d3e3a9
Don't fail an assertion and don't return FALSE if we can't create
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1112 | "Could not create %s. Certificates will not be cached.\n", |
|
135010d3e3a9
Don't fail an assertion and don't return FALSE if we can't create
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1113 | poolpath); |
|
135010d3e3a9
Don't fail an assertion and don't return FALSE if we can't create
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1114 | |
|
18574
ee5a638ce111
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18573
diff
changeset
|
1115 | g_free(poolpath); |
|
ee5a638ce111
- Add init for x509_tls_peers pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18573
diff
changeset
|
1116 | |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1117 | return TRUE; |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1118 | } |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1119 | |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1120 | static gboolean |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1121 | x509_tls_peers_cert_in_pool(const gchar *id) |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1122 | { |
|
18576
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1123 | gchar *keypath; |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1124 | gboolean ret = FALSE; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1125 | |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1126 | g_return_val_if_fail(id, FALSE); |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1127 | |
|
18576
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1128 | keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id); |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1129 | |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1130 | ret = g_file_test(keypath, G_FILE_TEST_IS_REGULAR); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1131 | |
|
18576
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1132 | g_free(keypath); |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1133 | return ret; |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1134 | } |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1135 | |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1136 | static PurpleCertificate * |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1137 | x509_tls_peers_get_cert(const gchar *id) |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1138 | { |
|
18576
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1139 | PurpleCertificateScheme *x509; |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1140 | PurpleCertificate *crt; |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1141 | gchar *keypath; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1142 | |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1143 | g_return_val_if_fail(id, NULL); |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1144 | |
|
18576
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1145 | /* Is it in the pool? */ |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1146 | if ( !x509_tls_peers_cert_in_pool(id) ) { |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1147 | return NULL; |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1148 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1149 | |
|
18576
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1150 | /* Look up the X.509 scheme */ |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1151 | x509 = purple_certificate_find_scheme("x509"); |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1152 | g_return_val_if_fail(x509, NULL); |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1153 | |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1154 | /* Okay, now find and load that key */ |
|
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1155 | keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id); |
|
18579
a479d0f12779
- Finish tls_peers get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18578
diff
changeset
|
1156 | crt = purple_certificate_import(x509, keypath); |
|
18576
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1157 | |
|
18579
a479d0f12779
- Finish tls_peers get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18578
diff
changeset
|
1158 | g_free(keypath); |
|
18576
d7d4ea071a48
- Finished tls_peers cert_in_pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18575
diff
changeset
|
1159 | |
|
18579
a479d0f12779
- Finish tls_peers get_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18578
diff
changeset
|
1160 | return crt; |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1161 | } |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1162 | |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1163 | static gboolean |
|
18571
abab131c242c
- CertificatePool put_cert now accepts an id argument
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18496
diff
changeset
|
1164 | x509_tls_peers_put_cert(const gchar *id, PurpleCertificate *crt) |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1165 | { |
|
18580
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1166 | gboolean ret = FALSE; |
|
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1167 | gchar *keypath; |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1168 | |
|
18580
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1169 | g_return_val_if_fail(crt, FALSE); |
|
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1170 | g_return_val_if_fail(crt->scheme, FALSE); |
|
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1171 | /* Make sure that this is some kind of X.509 certificate */ |
|
18581
26b562cc939d
- Comment change
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18580
diff
changeset
|
1172 | /* TODO: Perhaps just check crt->scheme->name instead? */ |
|
18580
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1173 | g_return_val_if_fail(crt->scheme == purple_certificate_find_scheme(x509_tls_peers.scheme_name), FALSE); |
|
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1174 | |
|
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1175 | /* Work out the filename and export */ |
|
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1176 | keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id); |
|
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1177 | ret = purple_certificate_export(keypath, crt); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1178 | |
|
18580
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1179 | g_free(keypath); |
|
9cd83ce5366d
- Add tls_peers put_cert
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18579
diff
changeset
|
1180 | return ret; |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1181 | } |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1182 | |
|
18897
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1183 | static gboolean |
|
18898
eb09543c2898
- remove_cert => delete_cert, because naming conventions are our
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18897
diff
changeset
|
1184 | x509_tls_peers_delete_cert(const gchar *id) |
|
18897
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1185 | { |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1186 | gboolean ret = FALSE; |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1187 | gchar *keypath; |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1188 | |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1189 | g_return_val_if_fail(id, FALSE); |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1190 | |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1191 | /* Is the id even in the pool? */ |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1192 | if (!x509_tls_peers_cert_in_pool(id)) { |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1193 | purple_debug_warning("certificate/tls_peers", |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1194 | "Id %s wasn't in the pool\n", |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1195 | id); |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1196 | return FALSE; |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1197 | } |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1198 | |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1199 | /* OK, so work out the keypath and delete the thing */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1200 | keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id); |
|
18897
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1201 | if ( unlink(keypath) != 0 ) { |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1202 | purple_debug_error("certificate/tls_peers", |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1203 | "Unlink of %s failed!\n", |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1204 | keypath); |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1205 | ret = FALSE; |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1206 | } else { |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1207 | ret = TRUE; |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1208 | } |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1209 | |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1210 | g_free(keypath); |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1211 | return ret; |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1212 | } |
|
1f94d1ea37c3
- Write remove_cert function for tls_peers Pool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18896
diff
changeset
|
1213 | |
|
18662
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1214 | static GList * |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1215 | x509_tls_peers_get_idlist(void) |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1216 | { |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1217 | GList *idlist = NULL; |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1218 | GDir *dir; |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1219 | const gchar *entry; |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1220 | gchar *poolpath; |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1221 | |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1222 | /* Get a handle on the pool directory */ |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1223 | poolpath = purple_certificate_pool_mkpath(&x509_tls_peers, NULL); |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1224 | dir = g_dir_open(poolpath, |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1225 | 0, /* No flags */ |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1226 | NULL); /* Not interested in what the error is */ |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1227 | g_free(poolpath); |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1228 | |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1229 | g_return_val_if_fail(dir, NULL); |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1230 | |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1231 | /* Traverse the directory listing and create an idlist */ |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1232 | while ( (entry = g_dir_read_name(dir)) != NULL ) { |
|
19018
2ebe15f875a6
- tls_peers pool unescapes filenames in its directory, as it should
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19017
diff
changeset
|
1233 | /* Unescape the filename */ |
|
2ebe15f875a6
- tls_peers pool unescapes filenames in its directory, as it should
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19017
diff
changeset
|
1234 | const char *unescaped = purple_unescape_filename(entry); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1235 | |
|
18662
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1236 | /* Copy the entry name into our list (GLib owns the original |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1237 | string) */ |
|
19018
2ebe15f875a6
- tls_peers pool unescapes filenames in its directory, as it should
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19017
diff
changeset
|
1238 | idlist = g_list_prepend(idlist, g_strdup(unescaped)); |
|
18662
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1239 | } |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1240 | |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1241 | /* Release the directory */ |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1242 | g_dir_close(dir); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1243 | |
|
18662
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1244 | return idlist; |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1245 | } |
|
8d763d3e7784
- Add get_idlist support to tls_peers CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18661
diff
changeset
|
1246 | |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1247 | static PurpleCertificatePool x509_tls_peers = { |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1248 | "x509", /* Scheme name */ |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1249 | "tls_peers", /* Pool name */ |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1250 | N_("SSL Peers Cache"), /* User-friendly name */ |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1251 | NULL, /* Internal data */ |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1252 | x509_tls_peers_init, /* init */ |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1253 | NULL, /* uninit not required */ |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1254 | x509_tls_peers_cert_in_pool, /* Certificate exists? */ |
|
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1255 | x509_tls_peers_get_cert, /* Cert retriever */ |
|
18661
a3c1e2719e45
- Add pool_get_idlist / pool_destroy_idlist
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18659
diff
changeset
|
1256 | x509_tls_peers_put_cert, /* Cert writer */ |
|
18899
45bdab2558f8
- Add purple_certificate_pool_delete
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18898
diff
changeset
|
1257 | x509_tls_peers_delete_cert, /* Cert remover */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1258 | x509_tls_peers_get_idlist, /* idlist retriever */ |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1259 | |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1260 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1261 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1262 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1263 | NULL |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1264 | }; |
|
18582
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1265 | |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1266 | |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1267 | /***** A Verifier that uses the tls_peers cache and the CA pool to validate certificates *****/ |
|
18582
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1268 | static PurpleCertificateVerifier x509_tls_cached; |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1269 | |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1270 | |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1271 | static void |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1272 | x509_tls_cached_user_auth_accept_cb(PurpleCertificateVerificationRequest *vrq) |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1273 | { |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1274 | PurpleCertificatePool *tls_peers; |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1275 | gchar *cache_id; |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1276 | |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1277 | g_return_if_fail(vrq); |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1278 | |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1279 | tls_peers = purple_certificate_find_pool("x509", "tls_peers"); |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1280 | |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1281 | cache_id = vrq->subject_name; |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1282 | purple_debug_info("certificate/x509/tls_cached", |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1283 | "User ACCEPTED cert\nCaching first in chain for future use as %s...\n", |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1284 | cache_id); |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1285 | |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1286 | purple_certificate_pool_store(tls_peers, cache_id, vrq->cert_chain->data); |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1287 | |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1288 | purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_VALID); |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1289 | } |
|
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1290 | |
|
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1291 | static void |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1292 | x509_tls_cached_user_auth_reject_cb(PurpleCertificateVerificationRequest *vrq) |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1293 | { |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1294 | g_return_if_fail(vrq); |
|
18590
d240b212c2d4
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18589
diff
changeset
|
1295 | |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1296 | purple_debug_warning("certificate/x509/tls_cached", "User REJECTED cert\n"); |
|
19031
1ba9955f993a
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19030
diff
changeset
|
1297 | |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
1298 | purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_REJECTED); |
|
19678
d19f50a6ac42
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19668
diff
changeset
|
1299 | } |
|
d19f50a6ac42
There's some disagreement over the response-id sent to the callbacks to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19668
diff
changeset
|
1300 | |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1301 | /** Validates a certificate by asking the user |
|
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1302 | * @param reason String to explain why the user needs to accept/refuse the |
|
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1303 | * certificate. |
|
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1304 | * @todo Needs a handle argument |
|
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1305 | */ |
|
18590
d240b212c2d4
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18589
diff
changeset
|
1306 | static void |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1307 | x509_tls_cached_user_auth(PurpleCertificateVerificationRequest *vrq, |
|
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1308 | const gchar *reason) |
|
18589
f828ef45c34e
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18588
diff
changeset
|
1309 | { |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1310 | gchar *primary; |
|
18590
d240b212c2d4
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18589
diff
changeset
|
1311 | |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1312 | primary = g_strdup_printf(_("Accept certificate for %s?"), |
|
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1313 | vrq->subject_name); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1314 | |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1315 | purple_request_certificate( |
|
18590
d240b212c2d4
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18589
diff
changeset
|
1316 | vrq->cb_data, /* TODO: Find what the handle ought to be */ |
|
d240b212c2d4
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18589
diff
changeset
|
1317 | _("SSL Certificate Verification"), |
|
d240b212c2d4
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18589
diff
changeset
|
1318 | primary, |
|
19490
732f7a5c075d
In tls_cached:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19489
diff
changeset
|
1319 | reason, |
|
32889
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1320 | vrq->cert_chain->data, |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1321 | _("Accept"), G_CALLBACK(x509_tls_cached_user_auth_accept_cb), |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1322 | _("Reject"), G_CALLBACK(x509_tls_cached_user_auth_reject_cb), |
|
b1a7793d2fe7
Use new certificate request API when prompting the user to accept certs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32885
diff
changeset
|
1323 | vrq); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1324 | |
|
18590
d240b212c2d4
- Wrote the logic for the "previously unknown host" condition in
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18589
diff
changeset
|
1325 | g_free(primary); |
|
18589
f828ef45c34e
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18588
diff
changeset
|
1326 | } |
|
f828ef45c34e
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18588
diff
changeset
|
1327 | |
|
f828ef45c34e
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18588
diff
changeset
|
1328 | static void |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1329 | x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq, |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
1330 | PurpleCertificateVerificationStatus flags); |
|
22050
c847558530de
If a peer certificate does not match our cached cert, do not auto reject it!
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22048
diff
changeset
|
1331 | |
|
c847558530de
If a peer certificate does not match our cached cert, do not auto reject it!
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22048
diff
changeset
|
1332 | static void |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1333 | x509_tls_cached_complete(PurpleCertificateVerificationRequest *vrq, |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
1334 | PurpleCertificateVerificationStatus flags) |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1335 | { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1336 | PurpleCertificatePool *tls_peers; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1337 | PurpleCertificate *peer_crt = vrq->cert_chain->data; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1338 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1339 | if (flags & PURPLE_CERTIFICATE_FATALS_MASK) { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1340 | /* TODO: Also print any other warnings? */ |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1341 | const gchar *error; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1342 | gchar *tmp, *secondary; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1343 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1344 | if (flags & PURPLE_CERTIFICATE_INVALID_CHAIN) |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1345 | error = invalidity_reason_to_string(PURPLE_CERTIFICATE_INVALID_CHAIN); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1346 | else if (flags & PURPLE_CERTIFICATE_REVOKED) |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1347 | error = invalidity_reason_to_string(PURPLE_CERTIFICATE_REVOKED); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1348 | else |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1349 | error = invalidity_reason_to_string(PURPLE_CERTIFICATE_UNKNOWN_ERROR); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1350 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1351 | tmp = g_strdup_printf(_("The certificate for %s could not be validated."), |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1352 | vrq->subject_name); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1353 | secondary = g_strconcat(tmp, " ", error, NULL); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1354 | g_free(tmp); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1355 | |
|
33636
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1356 | purple_debug_error("certificate/x509/tls_cached", |
|
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1357 | "Unable to validate certificate: %s\n", secondary); |
|
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1358 | |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1359 | purple_notify_error(NULL, /* TODO: Probably wrong. */ |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1360 | _("SSL Certificate Error"), |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1361 | _("Unable to validate certificate"), |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1362 | secondary); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1363 | g_free(secondary); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1364 | |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
1365 | purple_certificate_verify_complete(vrq, flags); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1366 | return; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1367 | } else if (flags & PURPLE_CERTIFICATE_NON_FATALS_MASK) { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1368 | /* Non-fatal error. Prompt the user. */ |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1369 | gchar *tmp; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1370 | GString *errors; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1371 | guint32 i = 1; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1372 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1373 | tmp = g_strdup_printf(_("The certificate for %s could not be validated."), |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1374 | vrq->subject_name); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1375 | errors = g_string_new(tmp); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1376 | g_free(tmp); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1377 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1378 | errors = g_string_append_c(errors, '\n'); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1379 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1380 | /* Special case a name mismatch because we want to display the two names... */ |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1381 | if (flags & PURPLE_CERTIFICATE_NAME_MISMATCH) { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1382 | gchar *sn = purple_certificate_get_subject_name(peer_crt); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1383 | |
|
28691
8f8d9963f92d
Print that specific message only when there is a CN; otherwise fall back
Paul Aurich <darkrain42@pidgin.im>
parents:
28690
diff
changeset
|
1384 | if (sn) { |
|
8f8d9963f92d
Print that specific message only when there is a CN; otherwise fall back
Paul Aurich <darkrain42@pidgin.im>
parents:
28690
diff
changeset
|
1385 | g_string_append_printf(errors, _("The certificate claims to be " |
|
8f8d9963f92d
Print that specific message only when there is a CN; otherwise fall back
Paul Aurich <darkrain42@pidgin.im>
parents:
28690
diff
changeset
|
1386 | "from \"%s\" instead. This could mean that you are " |
|
8f8d9963f92d
Print that specific message only when there is a CN; otherwise fall back
Paul Aurich <darkrain42@pidgin.im>
parents:
28690
diff
changeset
|
1387 | "not connecting to the service you believe you are."), |
|
8f8d9963f92d
Print that specific message only when there is a CN; otherwise fall back
Paul Aurich <darkrain42@pidgin.im>
parents:
28690
diff
changeset
|
1388 | sn); |
|
8f8d9963f92d
Print that specific message only when there is a CN; otherwise fall back
Paul Aurich <darkrain42@pidgin.im>
parents:
28690
diff
changeset
|
1389 | g_free(sn); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1390 | |
|
28691
8f8d9963f92d
Print that specific message only when there is a CN; otherwise fall back
Paul Aurich <darkrain42@pidgin.im>
parents:
28690
diff
changeset
|
1391 | flags &= ~PURPLE_CERTIFICATE_NAME_MISMATCH; |
|
8f8d9963f92d
Print that specific message only when there is a CN; otherwise fall back
Paul Aurich <darkrain42@pidgin.im>
parents:
28690
diff
changeset
|
1392 | } |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1393 | } |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1394 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1395 | while (i != PURPLE_CERTIFICATE_LAST) { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1396 | if (flags & i) { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1397 | errors = g_string_append_c(errors, '\n'); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1398 | g_string_append(errors, invalidity_reason_to_string(i)); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1399 | } |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1400 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1401 | i <<= 1; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1402 | } |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1403 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1404 | x509_tls_cached_user_auth(vrq, errors->str); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1405 | g_string_free(errors, TRUE); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1406 | return; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1407 | } |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1408 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1409 | /* If we reach this point, the certificate is good. */ |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1410 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1411 | /* Look up the local cache and store it there for future use */ |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1412 | tls_peers = purple_certificate_find_pool(x509_tls_cached.scheme_name, |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1413 | "tls_peers"); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1414 | if (tls_peers) { |
|
29042
5c056c4502b7
*** Plucked rev 8549b9a30115559965e9bf93bb15a45b04c1d149 (f05c54b03e6bbfdbff38c01697fbd353a969e05e):
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
1415 | if (!purple_certificate_pool_store(tls_peers,vrq->subject_name, |
|
5c056c4502b7
*** Plucked rev 8549b9a30115559965e9bf93bb15a45b04c1d149 (f05c54b03e6bbfdbff38c01697fbd353a969e05e):
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
1416 | peer_crt)) { |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1417 | purple_debug_error("certificate/x509/tls_cached", |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1418 | "FAILED to cache peer certificate\n"); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1419 | } |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1420 | } else { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1421 | purple_debug_error("certificate/x509/tls_cached", |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1422 | "Unable to locate tls_peers certificate cache.\n"); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1423 | } |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1424 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1425 | purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_VALID); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1426 | } |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1427 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1428 | static void |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1429 | x509_tls_cached_cert_in_cache(PurpleCertificateVerificationRequest *vrq, |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
1430 | PurpleCertificateVerificationStatus flags) |
|
19026
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1431 | { |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1432 | /* TODO: Looking this up by name over and over is expensive. |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1433 | Fix, please! */ |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1434 | PurpleCertificatePool *tls_peers = |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1435 | purple_certificate_find_pool(x509_tls_cached.scheme_name, |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1436 | "tls_peers"); |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1437 | |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1438 | /* The peer's certificate should be the first in the list */ |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1439 | PurpleCertificate *peer_crt = |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1440 | (PurpleCertificate *) vrq->cert_chain->data; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1441 | |
|
19026
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1442 | PurpleCertificate *cached_crt; |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1443 | GByteArray *peer_fpr, *cached_fpr; |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1444 | |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1445 | /* Load up the cached certificate */ |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1446 | cached_crt = purple_certificate_pool_retrieve( |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1447 | tls_peers, vrq->subject_name); |
|
19715
b548029f18aa
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19697
diff
changeset
|
1448 | if ( !cached_crt ) { |
|
27823
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27788
diff
changeset
|
1449 | purple_debug_warning("certificate/x509/tls_cached", |
|
19715
b548029f18aa
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19697
diff
changeset
|
1450 | "Lookup failed on cached certificate!\n" |
|
27823
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27788
diff
changeset
|
1451 | "Falling back to full verification.\n"); |
|
8eb52a9d3a6d
Continue verification when we can't find a *cached* peer. Fixes #9664.
Paul Aurich <darkrain42@pidgin.im>
parents:
27788
diff
changeset
|
1452 | /* vrq now becomes the problem of unknown_peer */ |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1453 | x509_tls_cached_unknown_peer(vrq, flags); |
|
25275
b28406cfe56a
Prevent a NULL ptr deref when unexpected stuff happens in the cert cache. Fixes #7776,#7769
Daniel Atallah <datallah@pidgin.im>
parents:
25165
diff
changeset
|
1454 | return; |
|
19715
b548029f18aa
- Remove g_assert()s. Fixes #2859
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19697
diff
changeset
|
1455 | } |
|
19026
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1456 | |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1457 | /* Now get SHA1 sums for both and compare them */ |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1458 | /* TODO: This is not an elegant way to compare certs */ |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1459 | peer_fpr = purple_certificate_get_fingerprint_sha1(peer_crt); |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1460 | cached_fpr = purple_certificate_get_fingerprint_sha1(cached_crt); |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1461 | if (!memcmp(peer_fpr->data, cached_fpr->data, peer_fpr->len)) { |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1462 | purple_debug_info("certificate/x509/tls_cached", |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1463 | "Peer cert matched cached\n"); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1464 | x509_tls_cached_complete(vrq, flags); |
|
19026
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1465 | } else { |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
25905
diff
changeset
|
1466 | purple_debug_error("certificate/x509/tls_cached", |
|
19026
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1467 | "Peer cert did NOT match cached\n"); |
|
22050
c847558530de
If a peer certificate does not match our cached cert, do not auto reject it!
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22048
diff
changeset
|
1468 | /* vrq now becomes the problem of the user */ |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1469 | x509_tls_cached_unknown_peer(vrq, flags); |
|
19026
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1470 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1471 | |
|
19026
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1472 | purple_certificate_destroy(cached_crt); |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1473 | g_byte_array_free(peer_fpr, TRUE); |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1474 | g_byte_array_free(cached_fpr, TRUE); |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1475 | } |
|
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1476 | |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1477 | /* |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1478 | * This is called from two points in x509_tls_cached_unknown_peer below |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1479 | * once we've verified the signature chain is valid. Now we need to verify |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1480 | * the subject name of the certificate. |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1481 | */ |
|
19025
8b4c3e863a53
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
1482 | static void |
|
28032
fdb1cd9da99b
cert: Validate subject name before prompting due to no CA pool.
Paul Aurich <darkrain42@pidgin.im>
parents:
27999
diff
changeset
|
1483 | x509_tls_cached_check_subject_name(PurpleCertificateVerificationRequest *vrq, |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
1484 | PurpleCertificateVerificationStatus flags) |
|
19025
8b4c3e863a53
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
1485 | { |
|
27936
1763b40b18bd
Fix GnuTLS validation of the CACert Chain. Closes #4458.
Paul Aurich <darkrain42@pidgin.im>
parents:
27934
diff
changeset
|
1486 | PurpleCertificate *peer_crt; |
|
19029
d7a6db2a1edd
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19028
diff
changeset
|
1487 | GList *chain = vrq->cert_chain; |
|
d7a6db2a1edd
- Wrote a tls_cached unknown_peer function that does many fun things,
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19028
diff
changeset
|
1488 | |
|
19030
e2bf9dcb2b72
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19029
diff
changeset
|
1489 | peer_crt = (PurpleCertificate *) chain->data; |
|
e2bf9dcb2b72
- Add HOSTNAME CHECKING to tls_cached unknown_peer mode, which is kind
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19029
diff
changeset
|
1490 | |
|
22048
be245d92600e
Add the StartCom Free SSL Certificate Authority certificate (as used by
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22006
diff
changeset
|
1491 | /* Last, check that the hostname matches */ |
|
be245d92600e
Add the StartCom Free SSL Certificate Authority certificate (as used by
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22006
diff
changeset
|
1492 | if ( ! purple_certificate_check_subject_name(peer_crt, |
|
be245d92600e
Add the StartCom Free SSL Certificate Authority certificate (as used by
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22006
diff
changeset
|
1493 | vrq->subject_name) ) { |
|
be245d92600e
Add the StartCom Free SSL Certificate Authority certificate (as used by
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22006
diff
changeset
|
1494 | gchar *sn = purple_certificate_get_subject_name(peer_crt); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1495 | |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1496 | flags |= PURPLE_CERTIFICATE_NAME_MISMATCH; |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
25905
diff
changeset
|
1497 | purple_debug_error("certificate/x509/tls_cached", |
|
22048
be245d92600e
Add the StartCom Free SSL Certificate Authority certificate (as used by
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22006
diff
changeset
|
1498 | "Name mismatch: Certificate given for %s " |
|
be245d92600e
Add the StartCom Free SSL Certificate Authority certificate (as used by
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22006
diff
changeset
|
1499 | "has a name of %s\n", |
|
be245d92600e
Add the StartCom Free SSL Certificate Authority certificate (as used by
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22006
diff
changeset
|
1500 | vrq->subject_name, sn); |
|
29982
e2a8f797a521
A couple more leak fixes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29930
diff
changeset
|
1501 | g_free(sn); |
|
28032
fdb1cd9da99b
cert: Validate subject name before prompting due to no CA pool.
Paul Aurich <darkrain42@pidgin.im>
parents:
27999
diff
changeset
|
1502 | } |
|
fdb1cd9da99b
cert: Validate subject name before prompting due to no CA pool.
Paul Aurich <darkrain42@pidgin.im>
parents:
27999
diff
changeset
|
1503 | |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1504 | x509_tls_cached_complete(vrq, flags); |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1505 | } |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1506 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1507 | /* For when we've never communicated with this party before */ |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1508 | /* TODO: Need ways to specify possibly multiple problems with a cert, or at |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1509 | least reprioritize them. |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1510 | */ |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1511 | static void |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1512 | x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq, |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
1513 | PurpleCertificateVerificationStatus flags) |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1514 | { |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1515 | PurpleCertificatePool *ca; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1516 | PurpleCertificate *peer_crt; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1517 | PurpleCertificate *ca_crt, *end_crt; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1518 | PurpleCertificate *failing_crt; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1519 | GList *chain = vrq->cert_chain; |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1520 | GSList *ca_crts, *cur; |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1521 | GByteArray *last_fpr, *ca_fpr; |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1522 | gboolean valid = FALSE; |
|
31377
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1523 | gchar *ca_id, *ca2_id; |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1524 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1525 | peer_crt = (PurpleCertificate *) chain->data; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1526 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1527 | /* TODO: Figure out a way to check for a bad signature, as opposed to |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1528 | "not self-signed" */ |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1529 | if ( purple_certificate_signed_by(peer_crt, peer_crt) ) { |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1530 | flags |= PURPLE_CERTIFICATE_SELF_SIGNED; |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1531 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1532 | purple_debug_info("certificate/x509/tls_cached", |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1533 | "Certificate for %s is self-signed.\n", |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1534 | vrq->subject_name); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1535 | |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1536 | x509_tls_cached_check_subject_name(vrq, flags); |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1537 | return; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1538 | } /* if (self signed) */ |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1539 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1540 | ca = purple_certificate_find_pool(x509_tls_cached.scheme_name, "ca"); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1541 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1542 | /* Next, check that the certificate chain is valid */ |
|
32590
65bb6a842cdc
Remove the old deprecated purple_certificate_check_signature_chain.
Andrew Victor <andrew.victor@mxit.com>
parents:
31868
diff
changeset
|
1543 | if (!purple_certificate_check_signature_chain(chain, |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1544 | &failing_crt)) |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1545 | { |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1546 | gboolean chain_validated = FALSE; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1547 | /* |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1548 | * Check if the failing certificate is in the CA store. If it is, then |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1549 | * consider this fully validated. This works around issues with some |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1550 | * prominent intermediate CAs whose signature is md5WithRSAEncryption. |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1551 | * I'm looking at CACert Class 3 here. See #4458 for details. |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1552 | */ |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1553 | if (ca) { |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1554 | gchar *uid = purple_certificate_get_unique_id(failing_crt); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1555 | PurpleCertificate *ca_crt = purple_certificate_pool_retrieve(ca, uid); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1556 | if (ca_crt != NULL) { |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1557 | GByteArray *failing_fpr; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1558 | GByteArray *ca_fpr; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1559 | failing_fpr = purple_certificate_get_fingerprint_sha1(failing_crt); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1560 | ca_fpr = purple_certificate_get_fingerprint_sha1(ca_crt); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1561 | if (byte_arrays_equal(failing_fpr, ca_fpr)) { |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1562 | purple_debug_info("certificate/x509/tls_cached", |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1563 | "Full chain verification failed (probably a bad " |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1564 | "signature algorithm), but found the last " |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1565 | "certificate %s in the CA pool.\n", uid); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1566 | chain_validated = TRUE; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1567 | } |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1568 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1569 | g_byte_array_free(failing_fpr, TRUE); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1570 | g_byte_array_free(ca_fpr, TRUE); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1571 | } |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1572 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1573 | purple_certificate_destroy(ca_crt); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1574 | g_free(uid); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1575 | } |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1576 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1577 | /* |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1578 | * If we get here, either the cert matched the stuff right above |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1579 | * or it didn't, in which case we give up and complain to the user. |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1580 | */ |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1581 | if (!chain_validated) |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1582 | /* TODO: Tell the user where the chain broke? */ |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1583 | flags |= PURPLE_CERTIFICATE_INVALID_CHAIN; |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1584 | |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1585 | x509_tls_cached_check_subject_name(vrq, flags); |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1586 | return; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1587 | } /* if (signature chain not good) */ |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1588 | |
|
31377
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1589 | /* Next, attempt to verify the last certificate is signed by a trusted |
|
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1590 | * CA, or is a trusted CA (based on fingerprint). |
|
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1591 | */ |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1592 | /* If, for whatever reason, there is no Certificate Authority pool |
|
33636
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1593 | loaded, we'll verify the subject name and then warn about this. */ |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1594 | if ( !ca ) { |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1595 | purple_debug_error("certificate/x509/tls_cached", |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1596 | "No X.509 Certificate Authority pool " |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1597 | "could be found!\n"); |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1598 | |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1599 | flags |= PURPLE_CERTIFICATE_NO_CA_POOL; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1600 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1601 | x509_tls_cached_check_subject_name(vrq, flags); |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1602 | return; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1603 | } |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1604 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1605 | end_crt = g_list_last(chain)->data; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1606 | |
|
31377
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1607 | /* Attempt to look up the last certificate, and the last certificate's |
|
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1608 | * issuer. |
|
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1609 | */ |
|
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1610 | ca_id = purple_certificate_get_issuer_unique_id(end_crt); |
|
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1611 | ca2_id = purple_certificate_get_unique_id(end_crt); |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1612 | purple_debug_info("certificate/x509/tls_cached", |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1613 | "Checking for a CA with DN=%s\n", |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1614 | ca_id); |
|
31377
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1615 | purple_debug_info("certificate/x509/tls_cached", |
|
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1616 | "Also checking for a CA with DN=%s\n", |
|
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1617 | ca2_id); |
|
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1618 | ca_crts = g_slist_concat(x509_ca_get_certs(ca_id), x509_ca_get_certs(ca2_id)); |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1619 | if ( NULL == ca_crts ) { |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1620 | flags |= PURPLE_CERTIFICATE_CA_UNKNOWN; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1621 | |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1622 | purple_debug_warning("certificate/x509/tls_cached", |
|
31868
b1dbae4ba9a8
Remove duplicate word "found" in this debug message
Mark Doliner <markdoliner@pidgin.im>
parents:
31377
diff
changeset
|
1623 | "No Certificate Authorities with either DN " |
|
31377
c9d71d1096ec
certificate: Better validation of chains which have an intermediate signed w/ MD5.
Paul Aurich <darkrain42@pidgin.im>
parents:
31376
diff
changeset
|
1624 | "found. I'll prompt the user, I guess.\n"); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1625 | |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1626 | x509_tls_cached_check_subject_name(vrq, flags); |
|
33636
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1627 | g_free(ca_id); |
|
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1628 | g_free(ca2_id); |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1629 | return; |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1630 | } |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1631 | |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1632 | /* |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1633 | * Check the fingerprints; if they match, then this certificate *is* one |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1634 | * of the designated "trusted roots", and we don't need to verify the |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1635 | * signature. This is good because some of the older roots are self-signed |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1636 | * with bad hash algorithms that we don't want to allow in any other |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1637 | * circumstances (one of Verisign's root CAs is self-signed with MD2). |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1638 | * |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1639 | * If the fingerprints don't match, we'll fall back to checking the |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1640 | * signature. |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1641 | */ |
|
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1642 | last_fpr = purple_certificate_get_fingerprint_sha1(end_crt); |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1643 | for (cur = ca_crts; cur; cur = cur->next) { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1644 | ca_crt = cur->data; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1645 | ca_fpr = purple_certificate_get_fingerprint_sha1(ca_crt); |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1646 | |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1647 | if ( byte_arrays_equal(last_fpr, ca_fpr) || |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1648 | purple_certificate_signed_by(end_crt, ca_crt) ) |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1649 | { |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1650 | /* TODO: If signed_by ever returns a reason, maybe mention |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1651 | that, too. */ |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1652 | /* TODO: Also mention the CA involved. While I could do this |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1653 | now, a full DN is a little much with which to assault the |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1654 | user's poor, leaky eyes. */ |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1655 | valid = TRUE; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1656 | g_byte_array_free(ca_fpr, TRUE); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1657 | break; |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1658 | } |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1659 | |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1660 | g_byte_array_free(ca_fpr, TRUE); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1661 | } |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1662 | |
|
33636
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1663 | if (valid == FALSE) { |
|
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1664 | purple_debug_error("certificate/x509/tls_cached", |
|
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1665 | "Unable to verify final certificate %s signed by %s. " |
|
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1666 | "Not a trusted root or signed by a trusted root.\n", |
|
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1667 | ca2_id, ca_id); |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1668 | flags |= PURPLE_CERTIFICATE_INVALID_CHAIN; |
|
33636
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1669 | } |
|
31155
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1670 | |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1671 | g_slist_foreach(ca_crts, (GFunc)purple_certificate_destroy, NULL); |
|
757baa7d408f
Apply Stu's specific certificate changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30815
diff
changeset
|
1672 | g_slist_free(ca_crts); |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1673 | g_byte_array_free(last_fpr, TRUE); |
|
33636
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1674 | g_free(ca_id); |
|
2fdb0449cdff
Add some more certificate debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32892
diff
changeset
|
1675 | g_free(ca2_id); |
|
27999
986cae14de10
certs: Clean up the code a little, since I made it hard to follow.
Paul Aurich <darkrain42@pidgin.im>
parents:
27936
diff
changeset
|
1676 | |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1677 | x509_tls_cached_check_subject_name(vrq, flags); |
|
19025
8b4c3e863a53
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
1678 | } |
|
8b4c3e863a53
In tls_cached Verifier:
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19024
diff
changeset
|
1679 | |
|
18589
f828ef45c34e
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18588
diff
changeset
|
1680 | static void |
|
18582
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1681 | x509_tls_cached_start_verify(PurpleCertificateVerificationRequest *vrq) |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1682 | { |
|
18588
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1683 | const gchar *tls_peers_name = "tls_peers"; /* Name of local cache */ |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1684 | PurpleCertificatePool *tls_peers; |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1685 | time_t now; |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1686 | gint64 activation, expiration; |
|
33637
5e3eb38571fc
Merge PurpleCertificateInvalidityFlags and PurpleCertificateValidationStatus.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33636
diff
changeset
|
1687 | PurpleCertificateVerificationStatus flags = PURPLE_CERTIFICATE_VALID; |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1688 | gboolean ret; |
|
18588
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1689 | |
|
18582
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1690 | g_return_if_fail(vrq); |
|
18588
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1691 | |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1692 | purple_debug_info("certificate/x509/tls_cached", |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1693 | "Starting verify for %s\n", |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1694 | vrq->subject_name); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1695 | |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1696 | /* |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1697 | * Verify the first certificate (the main one) has been activated and |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1698 | * isn't expired, i.e. activation < now < expiration. |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1699 | */ |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1700 | now = time(NULL); |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1701 | ret = purple_certificate_get_times(vrq->cert_chain->data, &activation, |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1702 | &expiration); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1703 | if (!ret) { |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1704 | flags |= PURPLE_CERTIFICATE_EXPIRED | PURPLE_CERTIFICATE_NOT_ACTIVATED; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1705 | purple_debug_error("certificate/x509/tls_cached", |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1706 | "Failed to get validity times for certificate %s\n", |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1707 | vrq->subject_name); |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1708 | } else if (now > expiration) { |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1709 | #if GLIB_CHECK_VERSION(2,26,0) |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1710 | GDateTime *exp_dt = g_date_time_new_from_unix_local(expiration); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1711 | gchar *expir_str = g_date_time_format(exp_dt, "%c"); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1712 | g_date_time_unref(exp_dt); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1713 | #else |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1714 | gchar *expir_str = g_strdup(ctime(&expiration)); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1715 | #endif |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1716 | flags |= PURPLE_CERTIFICATE_EXPIRED; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1717 | purple_debug_error("certificate/x509/tls_cached", |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1718 | "Certificate %s expired at %s\n", |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1719 | vrq->subject_name, expir_str); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1720 | g_free(expir_str); |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1721 | } else if (now < activation) { |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1722 | #if GLIB_CHECK_VERSION(2,26,0) |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1723 | GDateTime *act_dt = g_date_time_new_from_unix_local(activation); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1724 | gchar *activ_str = g_date_time_format(act_dt, "%c"); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1725 | g_date_time_unref(act_dt); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1726 | #else |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1727 | gchar *activ_str = g_strdup(ctime(&activation)); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1728 | #endif |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1729 | flags |= PURPLE_CERTIFICATE_NOT_ACTIVATED; |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1730 | purple_debug_error("certificate/x509/tls_cached", |
|
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1731 | "Certificate %s is not yet valid, will be at %s\n", |
|
34246
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1732 | vrq->subject_name, activ_str); |
|
2ca1bb194693
Update certificate API to use 64-bit unsigned values instead of time_t.
Daniel Atallah <datallah@pidgin.im>
parents:
33774
diff
changeset
|
1733 | g_free(activ_str); |
|
27925
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1734 | } |
|
c84c4837876c
Check expiration/activation times on certificates. Closes #8226.
Paul Aurich <darkrain42@pidgin.im>
parents:
27823
diff
changeset
|
1735 | |
|
18588
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1736 | tls_peers = purple_certificate_find_pool(x509_tls_cached.scheme_name,tls_peers_name); |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1737 | |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1738 | if (!tls_peers) { |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1739 | purple_debug_error("certificate/x509/tls_cached", |
|
24182
0b128c580e0f
remove misleading portion of the debug line
Ka-Hing Cheung <khc@pidgin.im>
parents:
24014
diff
changeset
|
1740 | "Couldn't find local peers cache %s\n", |
|
18588
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1741 | tls_peers_name); |
|
19031
1ba9955f993a
- Remove all usage of purple_certificate_verify_destroy, as it is
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19030
diff
changeset
|
1742 | |
|
20143
5b005012e908
applied changes from 92e6c32278d711f0d5807c4d931b26162e4a720f
Richard Laager <rlaager@pidgin.im>
parents:
19864
diff
changeset
|
1743 | /* vrq now becomes the problem of unknown_peer */ |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1744 | x509_tls_cached_unknown_peer(vrq, flags); |
|
18588
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1745 | return; |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1746 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1747 | |
|
18588
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1748 | /* Check if the peer has a certificate cached already */ |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1749 | purple_debug_info("certificate/x509/tls_cached", |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1750 | "Checking for cached cert...\n"); |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1751 | if (purple_certificate_pool_contains(tls_peers, vrq->subject_name)) { |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1752 | purple_debug_info("certificate/x509/tls_cached", |
|
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1753 | "...Found cached cert\n"); |
|
19026
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1754 | /* vrq is now the responsibility of cert_in_cache */ |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1755 | x509_tls_cached_cert_in_cache(vrq, flags); |
|
19026
a814165b098f
- Move "certificate found in cache" out of tls_cached_start_verify into
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19025
diff
changeset
|
1756 | } else { |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
25905
diff
changeset
|
1757 | purple_debug_warning("certificate/x509/tls_cached", |
|
18588
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1758 | "...Not in cache\n"); |
|
18589
f828ef45c34e
- More skeletonizing for tls_cached logic.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18588
diff
changeset
|
1759 | /* vrq now becomes the problem of unknown_peer */ |
|
28332
b5fd0494b67d
certs: Allow for dealing with multiple things wrong with a cert.
Paul Aurich <darkrain42@pidgin.im>
parents:
28267
diff
changeset
|
1760 | x509_tls_cached_unknown_peer(vrq, flags); |
|
18588
91ad034f1904
- Made a logic skeleton for tls_cached verifier
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18585
diff
changeset
|
1761 | } |
|
18582
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1762 | } |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1763 | |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1764 | static void |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1765 | x509_tls_cached_destroy_request(PurpleCertificateVerificationRequest *vrq) |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1766 | { |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1767 | g_return_if_fail(vrq); |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1768 | } |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1769 | |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1770 | static PurpleCertificateVerifier x509_tls_cached = { |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1771 | "x509", /* Scheme name */ |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1772 | "tls_cached", /* Verifier name */ |
|
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1773 | x509_tls_cached_start_verify, /* Verification begin */ |
|
19827
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1774 | x509_tls_cached_destroy_request,/* Request cleanup */ |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1775 | |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1776 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1777 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1778 | NULL, |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1779 | NULL |
|
62c3805f723e
- Add purple_reserved fields to various structures.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19727
diff
changeset
|
1780 | |
|
18582
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1781 | }; |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1782 | |
|
18470
6a1deea19882
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18469
diff
changeset
|
1783 | /****************************************************************************/ |
|
6a1deea19882
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18469
diff
changeset
|
1784 | /* Subsystem */ |
|
6a1deea19882
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18469
diff
changeset
|
1785 | /****************************************************************************/ |
|
6a1deea19882
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18469
diff
changeset
|
1786 | void |
|
18477
47243c0d52c6
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18473
diff
changeset
|
1787 | purple_certificate_init(void) |
|
18470
6a1deea19882
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18469
diff
changeset
|
1788 | { |
|
18477
47243c0d52c6
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18473
diff
changeset
|
1789 | /* Register builtins */ |
|
18473
a7251d502f6a
- Add purple_certificate_get_fingerprint_sha1
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18472
diff
changeset
|
1790 | purple_certificate_register_verifier(&x509_singleuse); |
|
19033
8b046b73c2d6
- Add skeleton for X.509 Certificate Authority (x509_ca) CertificatePool
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19032
diff
changeset
|
1791 | purple_certificate_register_pool(&x509_ca); |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
1792 | purple_certificate_register_pool(&x509_tls_peers); |
|
18582
2341c741705b
- Add x509_tls_cached skeleton
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18581
diff
changeset
|
1793 | purple_certificate_register_verifier(&x509_tls_cached); |
|
18470
6a1deea19882
- Add purple_certificate_register_builtins
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18469
diff
changeset
|
1794 | } |
|
18466
881319eb171d
- Add certificate_destroy and certificate_destroy_list
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18463
diff
changeset
|
1795 | |
|
18477
47243c0d52c6
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18473
diff
changeset
|
1796 | void |
|
47243c0d52c6
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18473
diff
changeset
|
1797 | purple_certificate_uninit(void) |
|
47243c0d52c6
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18473
diff
changeset
|
1798 | { |
|
18659
89e08c113e68
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18658
diff
changeset
|
1799 | /* Unregister all Verifiers */ |
|
25467
9631ed4f4527
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25275
diff
changeset
|
1800 | g_list_foreach(cert_verifiers, (GFunc)purple_certificate_unregister_verifier, NULL); |
|
18659
89e08c113e68
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18658
diff
changeset
|
1801 | |
|
89e08c113e68
- Change certificate_uninit to unregister all Pools, Schemes, and
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18658
diff
changeset
|
1802 | /* Unregister all Pools */ |
|
25467
9631ed4f4527
Fix a crash on exit with a patch from im.pidgin.next.minor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25275
diff
changeset
|
1803 | g_list_foreach(cert_pools, (GFunc)purple_certificate_unregister_pool, NULL); |
|
18477
47243c0d52c6
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18473
diff
changeset
|
1804 | } |
|
47243c0d52c6
- Certificate system now has init and uninit like other systems
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18473
diff
changeset
|
1805 | |
|
18657
4932aaf945ea
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1806 | gpointer |
|
4932aaf945ea
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1807 | purple_certificate_get_handle(void) |
|
4932aaf945ea
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1808 | { |
|
4932aaf945ea
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1809 | static gint handle; |
|
4932aaf945ea
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1810 | return &handle; |
|
4932aaf945ea
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1811 | } |
|
4932aaf945ea
- Add purple_certificate_get_handle
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18656
diff
changeset
|
1812 | |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1813 | PurpleCertificateScheme * |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1814 | purple_certificate_find_scheme(const gchar *name) |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1815 | { |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1816 | PurpleCertificateScheme *scheme = NULL; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1817 | GList *l; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1818 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1819 | g_return_val_if_fail(name, NULL); |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1820 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1821 | /* Traverse the list of registered schemes and locate the |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1822 | one whose name matches */ |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1823 | for(l = cert_schemes; l; l = l->next) { |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1824 | scheme = (PurpleCertificateScheme *)(l->data); |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1825 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1826 | /* Name matches? that's our man */ |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1827 | if(!g_ascii_strcasecmp(scheme->name, name)) |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1828 | return scheme; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1829 | } |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1830 | |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1831 | purple_debug_warning("certificate", |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1832 | "CertificateScheme %s requested but not found.\n", |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1833 | name); |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1834 | |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1835 | /* TODO: Signalling and such? */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1836 | |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1837 | return NULL; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1838 | } |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1839 | |
|
18658
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1840 | GList * |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1841 | purple_certificate_get_schemes(void) |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1842 | { |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1843 | return cert_schemes; |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1844 | } |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1845 | |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1846 | gboolean |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1847 | purple_certificate_register_scheme(PurpleCertificateScheme *scheme) |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1848 | { |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1849 | g_return_val_if_fail(scheme != NULL, FALSE); |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1850 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1851 | /* Make sure no scheme is registered with the same name */ |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1852 | if (purple_certificate_find_scheme(scheme->name) != NULL) { |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1853 | return FALSE; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1854 | } |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1855 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1856 | /* Okay, we're golden. Register it. */ |
|
18491
2aa829b48785
- prepend > append
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18490
diff
changeset
|
1857 | cert_schemes = g_list_prepend(cert_schemes, scheme); |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1858 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1859 | /* TODO: Signalling and such? */ |
|
19003
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1860 | |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1861 | purple_debug_info("certificate", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1862 | "CertificateScheme %s registered\n", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1863 | scheme->name); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1864 | |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1865 | return TRUE; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
1866 | } |
|
18446
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1867 | |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1868 | gboolean |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1869 | purple_certificate_unregister_scheme(PurpleCertificateScheme *scheme) |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1870 | { |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1871 | if (NULL == scheme) { |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1872 | purple_debug_warning("certificate", |
|
18492
1ebf50a37d55
- Fix some errors and return values
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18491
diff
changeset
|
1873 | "Attempting to unregister NULL scheme\n"); |
|
1ebf50a37d55
- Fix some errors and return values
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18491
diff
changeset
|
1874 | return FALSE; |
|
18446
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1875 | } |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1876 | |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1877 | /* TODO: signalling? */ |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1878 | |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1879 | /* TODO: unregister all CertificateVerifiers for this scheme?*/ |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1880 | /* TODO: unregister all CertificatePools for this scheme? */ |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1881 | /* Neither of the above should be necessary, though */ |
|
18446
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1882 | cert_schemes = g_list_remove(cert_schemes, scheme); |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1883 | |
|
19003
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1884 | purple_debug_info("certificate", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1885 | "CertificateScheme %s unregistered\n", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1886 | scheme->name); |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1887 | |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1888 | |
|
18446
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1889 | return TRUE; |
|
3e79caab7088
- Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18251
diff
changeset
|
1890 | } |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1891 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1892 | PurpleCertificateVerifier * |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1893 | purple_certificate_find_verifier(const gchar *scheme_name, const gchar *ver_name) |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1894 | { |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1895 | PurpleCertificateVerifier *vr = NULL; |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1896 | GList *l; |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1897 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1898 | g_return_val_if_fail(scheme_name, NULL); |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1899 | g_return_val_if_fail(ver_name, NULL); |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1900 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1901 | /* Traverse the list of registered verifiers and locate the |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1902 | one whose name matches */ |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1903 | for(l = cert_verifiers; l; l = l->next) { |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1904 | vr = (PurpleCertificateVerifier *)(l->data); |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1905 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1906 | /* Scheme and name match? */ |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1907 | if(!g_ascii_strcasecmp(vr->scheme_name, scheme_name) && |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1908 | !g_ascii_strcasecmp(vr->name, ver_name)) |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1909 | return vr; |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1910 | } |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1911 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1912 | purple_debug_warning("certificate", |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1913 | "CertificateVerifier %s, %s requested but not found.\n", |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1914 | scheme_name, ver_name); |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1915 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1916 | /* TODO: Signalling and such? */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1917 | |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1918 | return NULL; |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1919 | } |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1920 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1921 | |
|
18658
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1922 | GList * |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1923 | purple_certificate_get_verifiers(void) |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1924 | { |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1925 | return cert_verifiers; |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1926 | } |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
1927 | |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1928 | gboolean |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1929 | purple_certificate_register_verifier(PurpleCertificateVerifier *vr) |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1930 | { |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1931 | g_return_val_if_fail(vr != NULL, FALSE); |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1932 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1933 | /* Make sure no verifier is registered with the same scheme/name */ |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1934 | if (purple_certificate_find_verifier(vr->scheme_name, vr->name) != NULL) { |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1935 | return FALSE; |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1936 | } |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1937 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1938 | /* Okay, we're golden. Register it. */ |
|
18491
2aa829b48785
- prepend > append
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18490
diff
changeset
|
1939 | cert_verifiers = g_list_prepend(cert_verifiers, vr); |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1940 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1941 | /* TODO: Signalling and such? */ |
|
19003
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1942 | |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1943 | purple_debug_info("certificate", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1944 | "CertificateVerifier %s registered\n", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1945 | vr->name); |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1946 | return TRUE; |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1947 | } |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1948 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1949 | gboolean |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1950 | purple_certificate_unregister_verifier(PurpleCertificateVerifier *vr) |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1951 | { |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1952 | if (NULL == vr) { |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1953 | purple_debug_warning("certificate", |
|
18492
1ebf50a37d55
- Fix some errors and return values
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18491
diff
changeset
|
1954 | "Attempting to unregister NULL verifier\n"); |
|
1ebf50a37d55
- Fix some errors and return values
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18491
diff
changeset
|
1955 | return FALSE; |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1956 | } |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1957 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1958 | /* TODO: signalling? */ |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1959 | |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1960 | cert_verifiers = g_list_remove(cert_verifiers, vr); |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1961 | |
|
19003
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1962 | |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1963 | purple_debug_info("certificate", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1964 | "CertificateVerifier %s unregistered\n", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1965 | vr->name); |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
1966 | |
|
18461
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1967 | return TRUE; |
|
8ae1cd456532
- CertificateVerifier register/unregister/find
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18446
diff
changeset
|
1968 | } |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1969 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1970 | PurpleCertificatePool * |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1971 | purple_certificate_find_pool(const gchar *scheme_name, const gchar *pool_name) |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1972 | { |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1973 | PurpleCertificatePool *pool = NULL; |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1974 | GList *l; |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1975 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1976 | g_return_val_if_fail(scheme_name, NULL); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1977 | g_return_val_if_fail(pool_name, NULL); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1978 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1979 | /* Traverse the list of registered pools and locate the |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1980 | one whose name matches */ |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1981 | for(l = cert_pools; l; l = l->next) { |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1982 | pool = (PurpleCertificatePool *)(l->data); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1983 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1984 | /* Scheme and name match? */ |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1985 | if(!g_ascii_strcasecmp(pool->scheme_name, scheme_name) && |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1986 | !g_ascii_strcasecmp(pool->name, pool_name)) |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1987 | return pool; |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1988 | } |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1989 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1990 | purple_debug_warning("certificate", |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1991 | "CertificatePool %s, %s requested but not found.\n", |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1992 | scheme_name, pool_name); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1993 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1994 | /* TODO: Signalling and such? */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
1995 | |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1996 | return NULL; |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1997 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1998 | } |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
1999 | |
|
18658
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
2000 | GList * |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
2001 | purple_certificate_get_pools(void) |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
2002 | { |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
2003 | return cert_pools; |
|
2cc5bc32898a
- Add get_pools, get_verifiers, and get_schemes
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18657
diff
changeset
|
2004 | } |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2005 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2006 | gboolean |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2007 | purple_certificate_register_pool(PurpleCertificatePool *pool) |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2008 | { |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2009 | g_return_val_if_fail(pool, FALSE); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2010 | g_return_val_if_fail(pool->scheme_name, FALSE); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2011 | g_return_val_if_fail(pool->name, FALSE); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2012 | g_return_val_if_fail(pool->fullname, FALSE); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2013 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2014 | /* Make sure no pools are registered under this name */ |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2015 | if (purple_certificate_find_pool(pool->scheme_name, pool->name)) { |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2016 | return FALSE; |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2017 | } |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2018 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2019 | /* Initialize the pool if needed */ |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2020 | if (pool->init) { |
|
21720
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2021 | gboolean success; |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2022 | |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
2023 | success = pool->init(); |
|
21720
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2024 | if (!success) |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2025 | return FALSE; |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2026 | } |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2027 | |
|
21720
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2028 | /* Register the Pool */ |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2029 | cert_pools = g_list_prepend(cert_pools, pool); |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2030 | |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2031 | /* TODO: Emit a signal that the pool got registered */ |
|
18894
1a00d2309d39
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18818
diff
changeset
|
2032 | |
|
21720
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2033 | PURPLE_DBUS_REGISTER_POINTER(pool, PurpleCertificatePool); |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2034 | purple_signal_register(pool, /* Signals emitted from pool */ |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2035 | "certificate-stored", |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2036 | purple_marshal_VOID__POINTER_POINTER, |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2037 | NULL, /* No callback return value */ |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2038 | 2, /* Two non-data arguments */ |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2039 | purple_value_new(PURPLE_TYPE_SUBTYPE, |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2040 | PURPLE_SUBTYPE_CERTIFICATEPOOL), |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2041 | purple_value_new(PURPLE_TYPE_STRING)); |
|
18894
1a00d2309d39
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18818
diff
changeset
|
2042 | |
|
21720
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2043 | purple_signal_register(pool, /* Signals emitted from pool */ |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2044 | "certificate-deleted", |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2045 | purple_marshal_VOID__POINTER_POINTER, |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2046 | NULL, /* No callback return value */ |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2047 | 2, /* Two non-data arguments */ |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2048 | purple_value_new(PURPLE_TYPE_SUBTYPE, |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2049 | PURPLE_SUBTYPE_CERTIFICATEPOOL), |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2050 | purple_value_new(PURPLE_TYPE_STRING)); |
|
19003
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
2051 | |
|
21720
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2052 | purple_debug_info("certificate", |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2053 | "CertificatePool %s registered\n", |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2054 | pool->name); |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2055 | |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21646
diff
changeset
|
2056 | return TRUE; |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2057 | } |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2058 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2059 | gboolean |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2060 | purple_certificate_unregister_pool(PurpleCertificatePool *pool) |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2061 | { |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2062 | if (NULL == pool) { |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2063 | purple_debug_warning("certificate", |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2064 | "Attempting to unregister NULL pool\n"); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2065 | return FALSE; |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2066 | } |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2067 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2068 | /* Check that the pool is registered */ |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2069 | if (!g_list_find(cert_pools, pool)) { |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2070 | purple_debug_warning("certificate", |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2071 | "Pool to unregister isn't registered!\n"); |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2072 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2073 | return FALSE; |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2074 | } |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2075 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2076 | /* Uninit the pool if needed */ |
|
19688
7eddbc94521c
(Un)Register the pools with DBus to avoid a runtime fit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19678
diff
changeset
|
2077 | PURPLE_DBUS_UNREGISTER_POINTER(pool); |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2078 | if (pool->uninit) { |
|
18494
fc93e7020e83
- CertificatePool member functions no longer accept a Pool instance, as Pools are expected to be singletons
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18492
diff
changeset
|
2079 | pool->uninit(); |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2080 | } |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2081 | |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2082 | cert_pools = g_list_remove(cert_pools, pool); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
2083 | |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2084 | /* TODO: Signalling? */ |
|
18894
1a00d2309d39
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18818
diff
changeset
|
2085 | purple_signal_unregister(pool, "certificate-stored"); |
|
1a00d2309d39
- Register the certificate-stored and certificate-deleted signals
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18818
diff
changeset
|
2086 | purple_signal_unregister(pool, "certificate-deleted"); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
2087 | |
|
19003
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
2088 | purple_debug_info("certificate", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
2089 | "CertificatePool %s unregistered\n", |
|
0998b8659565
- Add debugging babble for registers/unregisters
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19000
diff
changeset
|
2090 | pool->name); |
|
18490
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2091 | return TRUE; |
|
691b0b16f8be
- Add find, register, and unregister for CertificatePools
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18483
diff
changeset
|
2092 | } |
|
19489
772b691e901b
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19484
diff
changeset
|
2093 | |
|
772b691e901b
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19484
diff
changeset
|
2094 | /****************************************************************************/ |
|
772b691e901b
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19484
diff
changeset
|
2095 | /* Scheme-specific functions */ |
|
772b691e901b
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19484
diff
changeset
|
2096 | /****************************************************************************/ |
|
772b691e901b
- Add purple_certificate_display_x509
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19484
diff
changeset
|
2097 | |
|
22001
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
2098 | void purple_certificate_add_ca_search_path(const char *path) |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
2099 | { |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
2100 | if (g_list_find_custom(x509_ca_paths, path, (GCompareFunc)strcmp)) |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
2101 | return; |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
2102 | x509_ca_paths = g_list_append(x509_ca_paths, g_strdup(path)); |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
2103 | } |
|
80abe994a8f3
Patch from Florian Quèze (the InstantBird dude) to add a search path for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21646
diff
changeset
|
2104 |