OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // implementations. | 44 // implementations. |
45 | 45 |
46 // A somewhat opaque type used to encapsulate a certificate. | 46 // A somewhat opaque type used to encapsulate a certificate. |
47 // Wraps the SSL library's notion of a certificate, with reference counting. | 47 // Wraps the SSL library's notion of a certificate, with reference counting. |
48 // The SSLCertificate object is pretty much immutable once created. | 48 // The SSLCertificate object is pretty much immutable once created. |
49 // (The OpenSSL implementation only does reference counting and | 49 // (The OpenSSL implementation only does reference counting and |
50 // possibly caching of intermediate results.) | 50 // possibly caching of intermediate results.) |
51 class SSLCertificate { | 51 class SSLCertificate { |
52 public: | 52 public: |
53 // Parses and builds a certificate from a PEM encoded string. | 53 // Parses and builds a certificate from a PEM encoded string. |
54 // Returns NULL on failure. | 54 // Returns null on failure. |
55 // The length of the string representation of the certificate is | 55 // The length of the string representation of the certificate is |
56 // stored in *pem_length if it is non-NULL, and only if | 56 // stored in *pem_length if it is non-null, and only if |
57 // parsing was successful. | 57 // parsing was successful. |
58 // Caller is responsible for freeing the returned object. | 58 // Caller is responsible for freeing the returned object. |
59 static SSLCertificate* FromPEMString(const std::string& pem_string); | 59 static SSLCertificate* FromPEMString(const std::string& pem_string); |
60 virtual ~SSLCertificate() {} | 60 virtual ~SSLCertificate() {} |
61 | 61 |
62 // Returns a new SSLCertificate object instance wrapping the same | 62 // Returns a new SSLCertificate object instance wrapping the same |
63 // underlying certificate, including its chain if present. | 63 // underlying certificate, including its chain if present. |
64 // Caller is responsible for freeing the returned object. | 64 // Caller is responsible for freeing the returned object. |
65 virtual SSLCertificate* GetReference() const = 0; | 65 virtual SSLCertificate* GetReference() const = 0; |
66 | 66 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // with the same public key). | 209 // with the same public key). |
210 // This too is pretty much immutable once created. | 210 // This too is pretty much immutable once created. |
211 class SSLIdentity { | 211 class SSLIdentity { |
212 public: | 212 public: |
213 // Generates an identity (keypair and self-signed certificate). If | 213 // Generates an identity (keypair and self-signed certificate). If |
214 // |common_name| is non-empty, it will be used for the certificate's subject | 214 // |common_name| is non-empty, it will be used for the certificate's subject |
215 // and issuer name, otherwise a random string will be used. The key type and | 215 // and issuer name, otherwise a random string will be used. The key type and |
216 // parameters are defined in |key_param|. The certificate's lifetime in | 216 // parameters are defined in |key_param|. The certificate's lifetime in |
217 // seconds from the current time is defined in |certificate_lifetime|; it | 217 // seconds from the current time is defined in |certificate_lifetime|; it |
218 // should be a non-negative number. | 218 // should be a non-negative number. |
219 // Returns NULL on failure. | 219 // Returns null on failure. |
220 // Caller is responsible for freeing the returned object. | 220 // Caller is responsible for freeing the returned object. |
221 static SSLIdentity* GenerateWithExpiration(const std::string& common_name, | 221 static SSLIdentity* GenerateWithExpiration(const std::string& common_name, |
222 const KeyParams& key_param, | 222 const KeyParams& key_param, |
223 time_t certificate_lifetime); | 223 time_t certificate_lifetime); |
224 static SSLIdentity* Generate(const std::string& common_name, | 224 static SSLIdentity* Generate(const std::string& common_name, |
225 const KeyParams& key_param); | 225 const KeyParams& key_param); |
226 static SSLIdentity* Generate(const std::string& common_name, | 226 static SSLIdentity* Generate(const std::string& common_name, |
227 KeyType key_type); | 227 KeyType key_type); |
228 | 228 |
229 // Generates an identity with the specified validity period. | 229 // Generates an identity with the specified validity period. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 // |s| is not 0-terminated; its char count is defined by |length|. | 265 // |s| is not 0-terminated; its char count is defined by |length|. |
266 int64_t ASN1TimeToSec(const unsigned char* s, size_t length, bool long_format); | 266 int64_t ASN1TimeToSec(const unsigned char* s, size_t length, bool long_format); |
267 | 267 |
268 extern const char kPemTypeCertificate[]; | 268 extern const char kPemTypeCertificate[]; |
269 extern const char kPemTypeRsaPrivateKey[]; | 269 extern const char kPemTypeRsaPrivateKey[]; |
270 extern const char kPemTypeEcPrivateKey[]; | 270 extern const char kPemTypeEcPrivateKey[]; |
271 | 271 |
272 } // namespace rtc | 272 } // namespace rtc |
273 | 273 |
274 #endif // WEBRTC_BASE_SSLIDENTITY_H_ | 274 #endif // WEBRTC_BASE_SSLIDENTITY_H_ |
OLD | NEW |