Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(882)

Side by Side Diff: chromeos/network/client_cert_util.h

Issue 421113002: Use correct slot id for client certs in network config. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/network/client_cert_resolver_unittest.cc ('k') | chromeos/network/client_cert_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_ 5 #ifndef CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_
6 #define CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_ 6 #define CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "chromeos/chromeos_export.h" 12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/network/certificate_pattern.h" 13 #include "chromeos/network/certificate_pattern.h"
14 14
15 namespace base { 15 namespace base {
16 class DictionaryValue; 16 class DictionaryValue;
17 } 17 }
18 18
19 namespace net { 19 namespace net {
20 struct CertPrincipal; 20 struct CertPrincipal;
21 class X509Certificate; 21 class X509Certificate;
22 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; 22 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList;
23 } 23 }
24 24
25 namespace chromeos { 25 namespace chromeos {
26 26
27 class IssuerSubjectPattern;
28
29 namespace client_cert { 27 namespace client_cert {
30 28
31 enum ConfigType { 29 enum ConfigType {
32 CONFIG_TYPE_NONE, 30 CONFIG_TYPE_NONE,
33 CONFIG_TYPE_OPENVPN, 31 CONFIG_TYPE_OPENVPN,
34 CONFIG_TYPE_IPSEC, 32 CONFIG_TYPE_IPSEC,
35 CONFIG_TYPE_EAP 33 CONFIG_TYPE_EAP
36 }; 34 };
37 35
38 struct CHROMEOS_EXPORT ClientCertConfig { 36 struct CHROMEOS_EXPORT ClientCertConfig {
(...skipping 11 matching lines...) Expand all
50 CertificatePattern pattern; 48 CertificatePattern pattern;
51 }; 49 };
52 50
53 // Returns true only if any fields set in this pattern match exactly with 51 // Returns true only if any fields set in this pattern match exactly with
54 // similar fields in the principal. If organization_ or organizational_unit_ 52 // similar fields in the principal. If organization_ or organizational_unit_
55 // are set, then at least one of the organizations or units in the principal 53 // are set, then at least one of the organizations or units in the principal
56 // must match. 54 // must match.
57 bool CertPrincipalMatches(const IssuerSubjectPattern& pattern, 55 bool CertPrincipalMatches(const IssuerSubjectPattern& pattern,
58 const net::CertPrincipal& principal); 56 const net::CertPrincipal& principal);
59 57
60 // Fetches the matching certificate that has the latest valid start date.
61 // Returns a NULL refptr if there is no such match.
62 CHROMEOS_EXPORT scoped_refptr<net::X509Certificate> GetCertificateMatch(
63 const CertificatePattern& pattern,
64 const net::CertificateList& all_certs);
65
66 // Returns the PKCS11 id part of |cert_id|, which is expected to be the value of 58 // Returns the PKCS11 id part of |cert_id|, which is expected to be the value of
67 // the Shill property kEapCertIdProperty or kEapKeyIdProperty. 59 // the Shill property kEapCertIdProperty or kEapKeyIdProperty.
68 CHROMEOS_EXPORT std::string GetPkcs11IdFromEapCertId( 60 CHROMEOS_EXPORT std::string GetPkcs11IdFromEapCertId(
69 const std::string& cert_id); 61 const std::string& cert_id);
70 62
71 // If not empty, sets the TPM properties in |properties|. If |pkcs11_id| is not 63 // Sets the properties of a client cert and the TPM slot that it's contained in.
72 // NULL, also sets the ClientCertID. |cert_config_type| determines which 64 // |cert_config_type| determines which dictionary entries to set.
73 // dictionary entries to set.
74 CHROMEOS_EXPORT void SetShillProperties(const ConfigType cert_config_type, 65 CHROMEOS_EXPORT void SetShillProperties(const ConfigType cert_config_type,
75 const std::string& tpm_slot, 66 const int tpm_slot,
76 const std::string& tpm_pin, 67 const std::string& pkcs11_id,
77 const std::string* pkcs11_id,
78 base::DictionaryValue* properties); 68 base::DictionaryValue* properties);
79 69
70 // Like SetShillProperties but instead sets the properties to empty strings.
71 // This should be used to clear previously set client certificate properties.
72 CHROMEOS_EXPORT void SetEmptyShillProperties(const ConfigType cert_config_type,
73 base::DictionaryValue* properties);
74
80 // Returns true if all required configuration properties are set and not empty. 75 // Returns true if all required configuration properties are set and not empty.
81 bool IsCertificateConfigured(const client_cert::ConfigType cert_config_type, 76 bool IsCertificateConfigured(const client_cert::ConfigType cert_config_type,
82 const base::DictionaryValue& service_properties); 77 const base::DictionaryValue& service_properties);
83 78
84 // Determines the type of the CertificatePattern configuration, i.e. is it a 79 // Determines the type of the CertificatePattern configuration, i.e. is it a
85 // pattern within an EAP, IPsec or OpenVPN configuration. 80 // pattern within an EAP, IPsec or OpenVPN configuration.
86 CHROMEOS_EXPORT void OncToClientCertConfig( 81 CHROMEOS_EXPORT void OncToClientCertConfig(
87 const base::DictionaryValue& network_config, 82 const base::DictionaryValue& network_config,
88 ClientCertConfig* cert_config); 83 ClientCertConfig* cert_config);
89 84
90 } // namespace client_cert 85 } // namespace client_cert
91 86
92 } // namespace chromeos 87 } // namespace chromeos
93 88
94 #endif // CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_ 89 #endif // CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_
OLDNEW
« no previous file with comments | « chromeos/network/client_cert_resolver_unittest.cc ('k') | chromeos/network/client_cert_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698