OLD | NEW |
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // member is to be used to initialize the certificate and intermediates. | 102 // member is to be used to initialize the certificate and intermediates. |
103 // The data may further be encoded using PEM, specifying block names of | 103 // The data may further be encoded using PEM, specifying block names of |
104 // either "PKCS7" or "CERTIFICATE". | 104 // either "PKCS7" or "CERTIFICATE". |
105 FORMAT_PKCS7 = 1 << 2, | 105 FORMAT_PKCS7 = 1 << 2, |
106 | 106 |
107 // Automatically detect the format. | 107 // Automatically detect the format. |
108 FORMAT_AUTO = FORMAT_SINGLE_CERTIFICATE | FORMAT_PEM_CERT_SEQUENCE | | 108 FORMAT_AUTO = FORMAT_SINGLE_CERTIFICATE | FORMAT_PEM_CERT_SEQUENCE | |
109 FORMAT_PKCS7, | 109 FORMAT_PKCS7, |
110 }; | 110 }; |
111 | 111 |
| 112 // Creates a X509Certificate from the ground up. Used by tests that simulate |
| 113 // SSL connections. |
| 114 X509Certificate(const std::string& subject, const std::string& issuer, |
| 115 base::Time start_date, base::Time expiration_date); |
| 116 |
112 // Create an X509Certificate from a handle to the certificate object in the | 117 // Create an X509Certificate from a handle to the certificate object in the |
113 // underlying crypto library. |source| specifies where |cert_handle| comes | 118 // underlying crypto library. |source| specifies where |cert_handle| comes |
114 // from. Given two certificate handles for the same certificate, our | 119 // from. Given two certificate handles for the same certificate, our |
115 // certificate cache prefers the handle from the network because our HTTP | 120 // certificate cache prefers the handle from the network because our HTTP |
116 // cache isn't caching the corresponding intermediate CA certificates yet | 121 // cache isn't caching the corresponding intermediate CA certificates yet |
117 // (http://crbug.com/7065). | 122 // (http://crbug.com/7065). |
118 // The returned pointer must be stored in a scoped_refptr<X509Certificate>. | 123 // The returned pointer must be stored in a scoped_refptr<X509Certificate>. |
119 static X509Certificate* CreateFromHandle(OSCertHandle cert_handle, | 124 static X509Certificate* CreateFromHandle(OSCertHandle cert_handle, |
120 Source source, | 125 Source source, |
121 const OSCertHandles& intermediates); | 126 const OSCertHandles& intermediates); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // 1. Encryption without authentication and thus vulnerable to | 173 // 1. Encryption without authentication and thus vulnerable to |
169 // man-in-the-middle attacks. | 174 // man-in-the-middle attacks. |
170 // 2. Self-signed certificates cannot be revoked. | 175 // 2. Self-signed certificates cannot be revoked. |
171 // | 176 // |
172 // Use this certificate only after the above risks are acknowledged. | 177 // Use this certificate only after the above risks are acknowledged. |
173 static X509Certificate* CreateSelfSigned(base::RSAPrivateKey* key, | 178 static X509Certificate* CreateSelfSigned(base::RSAPrivateKey* key, |
174 const std::string& subject, | 179 const std::string& subject, |
175 uint32 serial_number, | 180 uint32 serial_number, |
176 base::TimeDelta valid_duration); | 181 base::TimeDelta valid_duration); |
177 | 182 |
178 // Creates a X509Certificate from the ground up. Used by tests that simulate | |
179 // SSL connections. | |
180 X509Certificate(const std::string& subject, const std::string& issuer, | |
181 base::Time start_date, base::Time expiration_date); | |
182 | |
183 // Appends a representation of this object to the given pickle. | 183 // Appends a representation of this object to the given pickle. |
184 void Persist(Pickle* pickle); | 184 void Persist(Pickle* pickle); |
185 | 185 |
186 // The subject of the certificate. For HTTPS server certificates, this | 186 // The subject of the certificate. For HTTPS server certificates, this |
187 // represents the web server. The common name of the subject should match | 187 // represents the web server. The common name of the subject should match |
188 // the host name of the web server. | 188 // the host name of the web server. |
189 const CertPrincipal& subject() const { return subject_; } | 189 const CertPrincipal& subject() const { return subject_; } |
190 | 190 |
191 // The issuer of the certificate. | 191 // The issuer of the certificate. |
192 const CertPrincipal& issuer() const { return issuer_; } | 192 const CertPrincipal& issuer() const { return issuer_; } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
376 // Where the certificate comes from. | 376 // Where the certificate comes from. |
377 Source source_; | 377 Source source_; |
378 | 378 |
379 DISALLOW_COPY_AND_ASSIGN(X509Certificate); | 379 DISALLOW_COPY_AND_ASSIGN(X509Certificate); |
380 }; | 380 }; |
381 | 381 |
382 } // namespace net | 382 } // namespace net |
383 | 383 |
384 #endif // NET_BASE_X509_CERTIFICATE_H_ | 384 #endif // NET_BASE_X509_CERTIFICATE_H_ |
OLD | NEW |