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

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

Issue 6612013: Add X509Certificate::VerifyCertName(string) API. This will be used... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | « no previous file | net/base/x509_certificate.cc » ('j') | net/base/x509_certificate_unittest.cc » ('J')
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 #pragma once 7 #pragma once
8 8
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // error is returned. 280 // error is returned.
281 // 281 //
282 // |flags| is bitwise OR'd of VerifyFlags. 282 // |flags| is bitwise OR'd of VerifyFlags.
283 // If VERIFY_REV_CHECKING_ENABLED is set in |flags|, certificate revocation 283 // If VERIFY_REV_CHECKING_ENABLED is set in |flags|, certificate revocation
284 // checking is performed. If VERIFY_EV_CERT is set in |flags| too, 284 // checking is performed. If VERIFY_EV_CERT is set in |flags| too,
285 // EV certificate verification is performed. 285 // EV certificate verification is performed.
286 int Verify(const std::string& hostname, 286 int Verify(const std::string& hostname,
287 int flags, 287 int flags,
288 CertVerifyResult* verify_result) const; 288 CertVerifyResult* verify_result) const;
289 289
290 // Verifies that |hostname| matches this certificate.
291 // Does not verify that the certificate is valid, only that the certificate
292 // matches this host.
293 // Returns true if it matches.
wtc 2011/03/03 19:38:46 IMPORTANT: Please document that this function may
Mike Belshe 2011/03/03 23:06:14 Done.
294 bool VerifyNameMatch(const std::string& hostname) const;
295
290 // This method returns the DER encoded certificate. 296 // This method returns the DER encoded certificate.
291 // If the return value is true then the DER encoded certificate is available. 297 // If the return value is true then the DER encoded certificate is available.
292 // The content of the DER encoded certificate is written to |encoded|. 298 // The content of the DER encoded certificate is written to |encoded|.
293 bool GetDEREncoded(std::string* encoded); 299 bool GetDEREncoded(std::string* encoded);
294 300
295 OSCertHandle os_cert_handle() const { return cert_handle_; } 301 OSCertHandle os_cert_handle() const { return cert_handle_; }
296 302
297 // Returns true if two OSCertHandles refer to identical certificates. 303 // Returns true if two OSCertHandles refer to identical certificates.
298 static bool IsSameOSCert(OSCertHandle a, OSCertHandle b); 304 static bool IsSameOSCert(OSCertHandle a, OSCertHandle b);
299 305
300 // Creates an OS certificate handle from the BER-encoded representation. 306 // Creates an OS certificate handle from the BER-encoded representation.
301 // Returns NULL on failure. 307 // Returns NULL on failure.
302 static OSCertHandle CreateOSCertHandleFromBytes(const char* data, 308 static OSCertHandle CreateOSCertHandleFromBytes(const char* data,
303 int length); 309 int length);
304 310
305 // Creates all possible OS certificate handles from |data| encoded in a 311 // Creates all possible OS certificate handles from |data| encoded in a
306 // specific |format|. Returns an empty collection on failure. 312 // specific |format|. Returns an empty collection on failure.
307 static OSCertHandles CreateOSCertHandlesFromBytes( 313 static OSCertHandles CreateOSCertHandlesFromBytes(
308 const char* data, int length, Format format); 314 const char* data, int length, Format format);
309 315
310 // Duplicates (or adds a reference to) an OS certificate handle. 316 // Duplicates (or adds a reference to) an OS certificate handle.
311 static OSCertHandle DupOSCertHandle(OSCertHandle cert_handle); 317 static OSCertHandle DupOSCertHandle(OSCertHandle cert_handle);
312 318
313 // Frees (or releases a reference to) an OS certificate handle. 319 // Frees (or releases a reference to) an OS certificate handle.
314 static void FreeOSCertHandle(OSCertHandle cert_handle); 320 static void FreeOSCertHandle(OSCertHandle cert_handle);
315 321
322 // Verifies that |hostname| matches one of the names in |cert_names|, based on
323 // TLS name matching rules, specifically following http://tools.ietf.org/html/ draft-saintandre-tls-server-id-check-09#section-4.4.3
324 // The members of |cert_names| must have been extracted from the Subject CN or
325 // SAN fields of a certificate.
wtc 2011/03/03 19:38:46 Please document the limitation that this does not
Mike Belshe 2011/03/03 23:06:14 Done.
326 static bool VerifyHostname(const std::string& hostname,
327 const std::vector<std::string>& cert_names);
328
316 private: 329 private:
317 friend class base::RefCountedThreadSafe<X509Certificate>; 330 friend class base::RefCountedThreadSafe<X509Certificate>;
318 friend class TestRootCerts; // For unit tests 331 friend class TestRootCerts; // For unit tests
319 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, Cache); 332 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, Cache);
320 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, IntermediateCertificates); 333 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, IntermediateCertificates);
321 334
322 // Construct an X509Certificate from a handle to the certificate object 335 // Construct an X509Certificate from a handle to the certificate object
323 // in the underlying crypto library. 336 // in the underlying crypto library.
324 X509Certificate(OSCertHandle cert_handle, Source source, 337 X509Certificate(OSCertHandle cert_handle, Source source,
325 const OSCertHandles& intermediates); 338 const OSCertHandles& intermediates);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 388
376 // Where the certificate comes from. 389 // Where the certificate comes from.
377 Source source_; 390 Source source_;
378 391
379 DISALLOW_COPY_AND_ASSIGN(X509Certificate); 392 DISALLOW_COPY_AND_ASSIGN(X509Certificate);
380 }; 393 };
381 394
382 } // namespace net 395 } // namespace net
383 396
384 #endif // NET_BASE_X509_CERTIFICATE_H_ 397 #endif // NET_BASE_X509_CERTIFICATE_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/x509_certificate.cc » ('j') | net/base/x509_certificate_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698