OLD | NEW |
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 NET_CERT_X509_CERTIFICATE_H_ | 5 #ifndef NET_CERT_X509_CERTIFICATE_H_ |
6 #define NET_CERT_X509_CERTIFICATE_H_ | 6 #define NET_CERT_X509_CERTIFICATE_H_ |
7 | 7 |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include <Security/SecBase.h> | 26 #include <Security/SecBase.h> |
27 #elif defined(USE_OPENSSL_CERTS) | 27 #elif defined(USE_OPENSSL_CERTS) |
28 // Forward declaration; real one in <x509.h> | 28 // Forward declaration; real one in <x509.h> |
29 typedef struct x509_st X509; | 29 typedef struct x509_st X509; |
30 typedef struct x509_store_st X509_STORE; | 30 typedef struct x509_store_st X509_STORE; |
31 #elif defined(USE_NSS_CERTS) | 31 #elif defined(USE_NSS_CERTS) |
32 // Forward declaration; real one in <cert.h> | 32 // Forward declaration; real one in <cert.h> |
33 struct CERTCertificateStr; | 33 struct CERTCertificateStr; |
34 #endif | 34 #endif |
35 | 35 |
| 36 namespace base { |
36 class Pickle; | 37 class Pickle; |
37 class PickleIterator; | 38 class PickleIterator; |
| 39 } |
38 | 40 |
39 namespace net { | 41 namespace net { |
40 | 42 |
41 class CRLSet; | 43 class CRLSet; |
42 class CertVerifyResult; | 44 class CertVerifyResult; |
43 | 45 |
44 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | 46 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; |
45 | 47 |
46 // X509Certificate represents a X.509 certificate, which is comprised a | 48 // X509Certificate represents a X.509 certificate, which is comprised a |
47 // particular identity or end-entity certificate, such as an SSL server | 49 // particular identity or end-entity certificate, such as an SSL server |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // then this will return the nickname specified upon creation. | 174 // then this will return the nickname specified upon creation. |
173 std::string GetDefaultNickname(CertType type) const; | 175 std::string GetDefaultNickname(CertType type) const; |
174 #endif | 176 #endif |
175 | 177 |
176 // Create an X509Certificate from the representation stored in the given | 178 // Create an X509Certificate from the representation stored in the given |
177 // pickle. The data for this object is found relative to the given | 179 // pickle. The data for this object is found relative to the given |
178 // pickle_iter, which should be passed to the pickle's various Read* methods. | 180 // pickle_iter, which should be passed to the pickle's various Read* methods. |
179 // Returns NULL on failure. | 181 // Returns NULL on failure. |
180 // | 182 // |
181 // The returned pointer must be stored in a scoped_refptr<X509Certificate>. | 183 // The returned pointer must be stored in a scoped_refptr<X509Certificate>. |
182 static X509Certificate* CreateFromPickle(PickleIterator* pickle_iter, | 184 static X509Certificate* CreateFromPickle(base::PickleIterator* pickle_iter, |
183 PickleType type); | 185 PickleType type); |
184 | 186 |
185 // Parses all of the certificates possible from |data|. |format| is a | 187 // Parses all of the certificates possible from |data|. |format| is a |
186 // bit-wise OR of Format, indicating the possible formats the | 188 // bit-wise OR of Format, indicating the possible formats the |
187 // certificates may have been serialized as. If an error occurs, an empty | 189 // certificates may have been serialized as. If an error occurs, an empty |
188 // collection will be returned. | 190 // collection will be returned. |
189 static CertificateList CreateCertificateListFromBytes(const char* data, | 191 static CertificateList CreateCertificateListFromBytes(const char* data, |
190 int length, | 192 int length, |
191 int format); | 193 int format); |
192 | 194 |
193 // Appends a representation of this object to the given pickle. | 195 // Appends a representation of this object to the given pickle. |
194 void Persist(Pickle* pickle); | 196 void Persist(base::Pickle* pickle); |
195 | 197 |
196 // The serial number, DER encoded, possibly including a leading 00 byte. | 198 // The serial number, DER encoded, possibly including a leading 00 byte. |
197 const std::string& serial_number() const { return serial_number_; } | 199 const std::string& serial_number() const { return serial_number_; } |
198 | 200 |
199 // The subject of the certificate. For HTTPS server certificates, this | 201 // The subject of the certificate. For HTTPS server certificates, this |
200 // represents the web server. The common name of the subject should match | 202 // represents the web server. The common name of the subject should match |
201 // the host name of the web server. | 203 // the host name of the web server. |
202 const CertPrincipal& subject() const { return subject_; } | 204 const CertPrincipal& subject() const { return subject_; } |
203 | 205 |
204 // The issuer of the certificate. | 206 // The issuer of the certificate. |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 const std::vector<std::string>& cert_san_ip_addrs, | 469 const std::vector<std::string>& cert_san_ip_addrs, |
468 bool* common_name_fallback_used); | 470 bool* common_name_fallback_used); |
469 | 471 |
470 // Reads a single certificate from |pickle_iter| and returns a | 472 // Reads a single certificate from |pickle_iter| and returns a |
471 // platform-specific certificate handle. The format of the certificate | 473 // platform-specific certificate handle. The format of the certificate |
472 // stored in |pickle_iter| is not guaranteed to be the same across different | 474 // stored in |pickle_iter| is not guaranteed to be the same across different |
473 // underlying cryptographic libraries, nor acceptable to CreateFromBytes(). | 475 // underlying cryptographic libraries, nor acceptable to CreateFromBytes(). |
474 // Returns an invalid handle, NULL, on failure. | 476 // Returns an invalid handle, NULL, on failure. |
475 // NOTE: This should not be used for any new code. It is provided for | 477 // NOTE: This should not be used for any new code. It is provided for |
476 // migration purposes and should eventually be removed. | 478 // migration purposes and should eventually be removed. |
477 static OSCertHandle ReadOSCertHandleFromPickle(PickleIterator* pickle_iter); | 479 static OSCertHandle ReadOSCertHandleFromPickle( |
| 480 base::PickleIterator* pickle_iter); |
478 | 481 |
479 // Writes a single certificate to |pickle| in DER form. Returns false on | 482 // Writes a single certificate to |pickle| in DER form. Returns false on |
480 // failure. | 483 // failure. |
481 static bool WriteOSCertHandleToPickle(OSCertHandle handle, Pickle* pickle); | 484 static bool WriteOSCertHandleToPickle(OSCertHandle handle, |
| 485 base::Pickle* pickle); |
482 | 486 |
483 // The subject of the certificate. | 487 // The subject of the certificate. |
484 CertPrincipal subject_; | 488 CertPrincipal subject_; |
485 | 489 |
486 // The issuer of the certificate. | 490 // The issuer of the certificate. |
487 CertPrincipal issuer_; | 491 CertPrincipal issuer_; |
488 | 492 |
489 // This certificate is not valid before |valid_start_| | 493 // This certificate is not valid before |valid_start_| |
490 base::Time valid_start_; | 494 base::Time valid_start_; |
491 | 495 |
(...skipping 23 matching lines...) Expand all Loading... |
515 // based on the type of the certificate. | 519 // based on the type of the certificate. |
516 std::string default_nickname_; | 520 std::string default_nickname_; |
517 #endif | 521 #endif |
518 | 522 |
519 DISALLOW_COPY_AND_ASSIGN(X509Certificate); | 523 DISALLOW_COPY_AND_ASSIGN(X509Certificate); |
520 }; | 524 }; |
521 | 525 |
522 } // namespace net | 526 } // namespace net |
523 | 527 |
524 #endif // NET_CERT_X509_CERTIFICATE_H_ | 528 #endif // NET_CERT_X509_CERTIFICATE_H_ |
OLD | NEW |