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_UTIL_H_ | 5 #ifndef NET_CERT_X509_UTIL_H_ |
6 #define NET_CERT_X509_UTIL_H_ | 6 #define NET_CERT_X509_UTIL_H_ |
7 | 7 |
| 8 #include <stdint.h> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
14 | 15 |
15 namespace crypto { | 16 namespace crypto { |
16 class ECPrivateKey; | 17 class ECPrivateKey; |
17 class RSAPrivateKey; | 18 class RSAPrivateKey; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // SECURITY WARNING | 50 // SECURITY WARNING |
50 // | 51 // |
51 // Using self-signed certificates has the following security risks: | 52 // Using self-signed certificates has the following security risks: |
52 // 1. Encryption without authentication and thus vulnerable to | 53 // 1. Encryption without authentication and thus vulnerable to |
53 // man-in-the-middle attacks. | 54 // man-in-the-middle attacks. |
54 // 2. Self-signed certificates cannot be revoked. | 55 // 2. Self-signed certificates cannot be revoked. |
55 // | 56 // |
56 // Use this certificate only after the above risks are acknowledged. | 57 // Use this certificate only after the above risks are acknowledged. |
57 NET_EXPORT bool CreateKeyAndSelfSignedCert( | 58 NET_EXPORT bool CreateKeyAndSelfSignedCert( |
58 const std::string& subject, | 59 const std::string& subject, |
59 uint32 serial_number, | 60 uint32_t serial_number, |
60 base::Time not_valid_before, | 61 base::Time not_valid_before, |
61 base::Time not_valid_after, | 62 base::Time not_valid_after, |
62 scoped_ptr<crypto::RSAPrivateKey>* key, | 63 scoped_ptr<crypto::RSAPrivateKey>* key, |
63 std::string* der_cert); | 64 std::string* der_cert); |
64 | 65 |
65 // Creates a self-signed certificate from a provided key, using the specified | 66 // Creates a self-signed certificate from a provided key, using the specified |
66 // hash algorithm. You should not re-use a key for signing data with multiple | 67 // hash algorithm. You should not re-use a key for signing data with multiple |
67 // signature algorithms or parameters. | 68 // signature algorithms or parameters. |
68 NET_EXPORT bool CreateSelfSignedCert(crypto::RSAPrivateKey* key, | 69 NET_EXPORT bool CreateSelfSignedCert(crypto::RSAPrivateKey* key, |
69 DigestAlgorithm alg, | 70 DigestAlgorithm alg, |
70 const std::string& subject, | 71 const std::string& subject, |
71 uint32 serial_number, | 72 uint32_t serial_number, |
72 base::Time not_valid_before, | 73 base::Time not_valid_before, |
73 base::Time not_valid_after, | 74 base::Time not_valid_after, |
74 std::string* der_cert); | 75 std::string* der_cert); |
75 | 76 |
76 // Comparator for use in STL algorithms that will sort client certificates by | 77 // Comparator for use in STL algorithms that will sort client certificates by |
77 // order of preference. | 78 // order of preference. |
78 // Returns true if |a| is more preferable than |b|, allowing it to be used | 79 // Returns true if |a| is more preferable than |b|, allowing it to be used |
79 // with any algorithm that compares according to strict weak ordering. | 80 // with any algorithm that compares according to strict weak ordering. |
80 // | 81 // |
81 // Criteria include: | 82 // Criteria include: |
(...skipping 11 matching lines...) Expand all Loading... |
93 | 94 |
94 private: | 95 private: |
95 base::Time now_; | 96 base::Time now_; |
96 }; | 97 }; |
97 | 98 |
98 } // namespace x509_util | 99 } // namespace x509_util |
99 | 100 |
100 } // namespace net | 101 } // namespace net |
101 | 102 |
102 #endif // NET_CERT_X509_UTIL_H_ | 103 #endif // NET_CERT_X509_UTIL_H_ |
OLD | NEW |