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

Side by Side Diff: net/base/x509_certificate.h

Issue 125120: Use LOAD_VERIFY_EV_CERT to verify EV-ness in Verify().... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « net/base/ssl_config_service.h ('k') | net/base/x509_certificate_mac.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 NET_BASE_X509_CERTIFICATE_H_ 5 #ifndef NET_BASE_X509_CERTIFICATE_H_
6 #define NET_BASE_X509_CERTIFICATE_H_ 6 #define NET_BASE_X509_CERTIFICATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 // Where the certificate comes from. The enumeration constants are 127 // Where the certificate comes from. The enumeration constants are
128 // listed in increasing order of preference. 128 // listed in increasing order of preference.
129 enum Source { 129 enum Source {
130 SOURCE_UNUSED = 0, // The source_ member is not used. 130 SOURCE_UNUSED = 0, // The source_ member is not used.
131 SOURCE_LONE_CERT_IMPORT = 1, // From importing a certificate without 131 SOURCE_LONE_CERT_IMPORT = 1, // From importing a certificate without
132 // its intermediate CA certificates. 132 // its intermediate CA certificates.
133 SOURCE_FROM_NETWORK = 2, // From the network. 133 SOURCE_FROM_NETWORK = 2, // From the network.
134 }; 134 };
135 135
136 enum VerifyFlags {
137 VERIFY_REV_CHECKING_ENABLED = 1 << 0,
138 VERIFY_EV_CERT = 1 << 1,
139 };
140
136 // Create an X509Certificate from a handle to the certificate object 141 // Create an X509Certificate from a handle to the certificate object
137 // in the underlying crypto library. This is a transfer of ownership; 142 // in the underlying crypto library. This is a transfer of ownership;
138 // X509Certificate will properly dispose of |cert_handle| for you. 143 // X509Certificate will properly dispose of |cert_handle| for you.
139 // |source| specifies where |cert_handle| comes from. Given two 144 // |source| specifies where |cert_handle| comes from. Given two
140 // certificate handles for the same certificate, our certificate cache 145 // certificate handles for the same certificate, our certificate cache
141 // prefers the handle from the network because our HTTP cache isn't 146 // prefers the handle from the network because our HTTP cache isn't
142 // caching the corresponding intermediate CA certificates yet 147 // caching the corresponding intermediate CA certificates yet
143 // (http://crbug.com/7065). 148 // (http://crbug.com/7065).
144 // 149 //
145 // The returned pointer must be stored in a scoped_refptr<X509Certificate>. 150 // The returned pointer must be stored in a scoped_refptr<X509Certificate>.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 205
201 // Verifies the certificate against the given hostname. Returns OK if 206 // Verifies the certificate against the given hostname. Returns OK if
202 // successful or an error code upon failure. 207 // successful or an error code upon failure.
203 // 208 //
204 // The |*verify_result| structure, including the |verify_result->cert_status| 209 // The |*verify_result| structure, including the |verify_result->cert_status|
205 // bitmask, is always filled out regardless of the return value. If the 210 // bitmask, is always filled out regardless of the return value. If the
206 // certificate has multiple errors, the corresponding status flags are set in 211 // certificate has multiple errors, the corresponding status flags are set in
207 // |verify_result->cert_status|, and the error code for the most serious 212 // |verify_result->cert_status|, and the error code for the most serious
208 // error is returned. 213 // error is returned.
209 // 214 //
210 // If |rev_checking_enabled| is true, certificate revocation checking is 215 // |flags| is bitwise OR'd of VerifyFlags.
211 // performed. 216 // If VERIFY_REV_CHECKING_ENABLED is set in |flags|, certificate revocation
217 // checking is performed. If VERIFY_EV_CERT is set in |flags| too,
218 // EV certificate verification is performed.
212 int Verify(const std::string& hostname, 219 int Verify(const std::string& hostname,
213 bool rev_checking_enabled, 220 int flags,
214 CertVerifyResult* verify_result) const; 221 CertVerifyResult* verify_result) const;
215 222
216 // Returns true if the certificate is an extended-validation (EV)
217 // certificate.
218 bool IsEV(int cert_status) const;
219
220 OSCertHandle os_cert_handle() const { return cert_handle_; } 223 OSCertHandle os_cert_handle() const { return cert_handle_; }
221 224
222 private: 225 private:
223 friend class base::RefCountedThreadSafe<X509Certificate>; 226 friend class base::RefCountedThreadSafe<X509Certificate>;
224 FRIEND_TEST(X509CertificateTest, Cache); 227 FRIEND_TEST(X509CertificateTest, Cache);
225 228
226 // A cache of X509Certificate objects. 229 // A cache of X509Certificate objects.
227 class Cache { 230 class Cache {
228 public: 231 public:
229 static Cache* GetInstance(); 232 static Cache* GetInstance();
(...skipping 21 matching lines...) Expand all
251 254
252 // Construct an X509Certificate from a handle to the certificate object 255 // Construct an X509Certificate from a handle to the certificate object
253 // in the underlying crypto library. 256 // in the underlying crypto library.
254 X509Certificate(OSCertHandle cert_handle, Source source); 257 X509Certificate(OSCertHandle cert_handle, Source source);
255 258
256 ~X509Certificate(); 259 ~X509Certificate();
257 260
258 // Common object initialization code. Called by the constructors only. 261 // Common object initialization code. Called by the constructors only.
259 void Initialize(); 262 void Initialize();
260 263
264 bool VerifyEV() const;
265
261 // Creates an OS certificate handle from the BER-encoded representation. 266 // Creates an OS certificate handle from the BER-encoded representation.
262 // Returns NULL on failure. 267 // Returns NULL on failure.
263 static OSCertHandle CreateOSCertHandleFromBytes(const char* data, 268 static OSCertHandle CreateOSCertHandleFromBytes(const char* data,
264 int length); 269 int length);
265 270
266 // Frees an OS certificate handle. 271 // Frees an OS certificate handle.
267 static void FreeOSCertHandle(OSCertHandle cert_handle); 272 static void FreeOSCertHandle(OSCertHandle cert_handle);
268 273
269 // Calculates the SHA-1 fingerprint of the certificate. Returns an empty 274 // Calculates the SHA-1 fingerprint of the certificate. Returns an empty
270 // (all zero) fingerprint on failure. 275 // (all zero) fingerprint on failure.
(...skipping 19 matching lines...) Expand all
290 295
291 // Where the certificate comes from. 296 // Where the certificate comes from.
292 Source source_; 297 Source source_;
293 298
294 DISALLOW_COPY_AND_ASSIGN(X509Certificate); 299 DISALLOW_COPY_AND_ASSIGN(X509Certificate);
295 }; 300 };
296 301
297 } // namespace net 302 } // namespace net
298 303
299 #endif // NET_BASE_X509_CERTIFICATE_H_ 304 #endif // NET_BASE_X509_CERTIFICATE_H_
OLDNEW
« no previous file with comments | « net/base/ssl_config_service.h ('k') | net/base/x509_certificate_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698