Chromium Code Reviews| 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 <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | |
| 12 | 13 |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/strings/string_piece.h" | |
| 14 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 15 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 16 | 18 |
| 17 namespace crypto { | 19 namespace crypto { |
| 18 class ECPrivateKey; | 20 class ECPrivateKey; |
| 19 class RSAPrivateKey; | 21 class RSAPrivateKey; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace net { | 24 namespace net { |
| 23 | 25 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 // hash algorithm. You should not re-use a key for signing data with multiple | 68 // hash algorithm. You should not re-use a key for signing data with multiple |
| 67 // signature algorithms or parameters. | 69 // signature algorithms or parameters. |
| 68 NET_EXPORT bool CreateSelfSignedCert(crypto::RSAPrivateKey* key, | 70 NET_EXPORT bool CreateSelfSignedCert(crypto::RSAPrivateKey* key, |
| 69 DigestAlgorithm alg, | 71 DigestAlgorithm alg, |
| 70 const std::string& subject, | 72 const std::string& subject, |
| 71 uint32_t serial_number, | 73 uint32_t serial_number, |
| 72 base::Time not_valid_before, | 74 base::Time not_valid_before, |
| 73 base::Time not_valid_after, | 75 base::Time not_valid_after, |
| 74 std::string* der_cert); | 76 std::string* der_cert); |
| 75 | 77 |
| 78 // Provides a method to parse a DER-encoded X509 certificate without calling any | |
|
davidben
2016/09/06 17:21:46
Nit: X509 -> X.509, also I think we usually write
| |
| 79 // OS primitives. This is useful in sandboxed processes. | |
| 80 NET_EXPORT bool ParseCertificateSandboxed( | |
| 81 const base::StringPiece& certificate, | |
| 82 std::string* subject, | |
| 83 std::string* issuer, | |
| 84 base::Time* not_before, | |
| 85 base::Time* not_after, | |
| 86 std::vector<std::string>* dns_names, | |
| 87 std::vector<std::string>* ip_addresses); | |
| 88 | |
| 76 // Comparator for use in STL algorithms that will sort client certificates by | 89 // Comparator for use in STL algorithms that will sort client certificates by |
| 77 // order of preference. | 90 // order of preference. |
| 78 // Returns true if |a| is more preferable than |b|, allowing it to be used | 91 // 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. | 92 // with any algorithm that compares according to strict weak ordering. |
| 80 // | 93 // |
| 81 // Criteria include: | 94 // Criteria include: |
| 82 // - Prefer certificates that have a longer validity period (later | 95 // - Prefer certificates that have a longer validity period (later |
| 83 // expiration dates) | 96 // expiration dates) |
| 84 // - If equal, prefer certificates that were issued more recently | 97 // - If equal, prefer certificates that were issued more recently |
| 85 // - If equal, prefer shorter chains (if available) | 98 // - If equal, prefer shorter chains (if available) |
| 86 class NET_EXPORT_PRIVATE ClientCertSorter { | 99 class NET_EXPORT_PRIVATE ClientCertSorter { |
| 87 public: | 100 public: |
| 88 ClientCertSorter(); | 101 ClientCertSorter(); |
| 89 | 102 |
| 90 bool operator()( | 103 bool operator()( |
| 91 const scoped_refptr<X509Certificate>& a, | 104 const scoped_refptr<X509Certificate>& a, |
| 92 const scoped_refptr<X509Certificate>& b) const; | 105 const scoped_refptr<X509Certificate>& b) const; |
| 93 | 106 |
| 94 private: | 107 private: |
| 95 base::Time now_; | 108 base::Time now_; |
| 96 }; | 109 }; |
| 97 | 110 |
| 98 } // namespace x509_util | 111 } // namespace x509_util |
| 99 | 112 |
| 100 } // namespace net | 113 } // namespace net |
| 101 | 114 |
| 102 #endif // NET_CERT_X509_UTIL_H_ | 115 #endif // NET_CERT_X509_UTIL_H_ |
| OLD | NEW |