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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 virtual OpenSSLKeyPair* GetReference(); | 39 virtual OpenSSLKeyPair* GetReference(); |
40 | 40 |
41 EVP_PKEY* pkey() const { return pkey_; } | 41 EVP_PKEY* pkey() const { return pkey_; } |
42 | 42 |
43 private: | 43 private: |
44 void AddReference(); | 44 void AddReference(); |
45 | 45 |
46 EVP_PKEY* pkey_; | 46 EVP_PKEY* pkey_; |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(OpenSSLKeyPair); | 48 RTC_DISALLOW_COPY_AND_ASSIGN(OpenSSLKeyPair); |
49 }; | 49 }; |
50 | 50 |
51 // OpenSSLCertificate encapsulates an OpenSSL X509* certificate object, | 51 // OpenSSLCertificate encapsulates an OpenSSL X509* certificate object, |
52 // which is also reference counted inside the OpenSSL library. | 52 // which is also reference counted inside the OpenSSL library. |
53 class OpenSSLCertificate : public SSLCertificate { | 53 class OpenSSLCertificate : public SSLCertificate { |
54 public: | 54 public: |
55 // Caller retains ownership of the X509 object. | 55 // Caller retains ownership of the X509 object. |
56 explicit OpenSSLCertificate(X509* x509) : x509_(x509) { | 56 explicit OpenSSLCertificate(X509* x509) : x509_(x509) { |
57 AddReference(); | 57 AddReference(); |
58 } | 58 } |
(...skipping 26 matching lines...) Expand all Loading... |
85 size_t* length); | 85 size_t* length); |
86 | 86 |
87 bool GetSignatureDigestAlgorithm(std::string* algorithm) const override; | 87 bool GetSignatureDigestAlgorithm(std::string* algorithm) const override; |
88 bool GetChain(SSLCertChain** chain) const override; | 88 bool GetChain(SSLCertChain** chain) const override; |
89 | 89 |
90 private: | 90 private: |
91 void AddReference() const; | 91 void AddReference() const; |
92 | 92 |
93 X509* x509_; | 93 X509* x509_; |
94 | 94 |
95 DISALLOW_COPY_AND_ASSIGN(OpenSSLCertificate); | 95 RTC_DISALLOW_COPY_AND_ASSIGN(OpenSSLCertificate); |
96 }; | 96 }; |
97 | 97 |
98 // Holds a keypair and certificate together, and a method to generate | 98 // Holds a keypair and certificate together, and a method to generate |
99 // them consistently. | 99 // them consistently. |
100 class OpenSSLIdentity : public SSLIdentity { | 100 class OpenSSLIdentity : public SSLIdentity { |
101 public: | 101 public: |
102 static OpenSSLIdentity* Generate(const std::string& common_name, | 102 static OpenSSLIdentity* Generate(const std::string& common_name, |
103 KeyType key_type); | 103 KeyType key_type); |
104 static OpenSSLIdentity* GenerateForTest(const SSLIdentityParams& params); | 104 static OpenSSLIdentity* GenerateForTest(const SSLIdentityParams& params); |
105 static SSLIdentity* FromPEMStrings(const std::string& private_key, | 105 static SSLIdentity* FromPEMStrings(const std::string& private_key, |
106 const std::string& certificate); | 106 const std::string& certificate); |
107 ~OpenSSLIdentity() override; | 107 ~OpenSSLIdentity() override; |
108 | 108 |
109 const OpenSSLCertificate& certificate() const override; | 109 const OpenSSLCertificate& certificate() const override; |
110 OpenSSLIdentity* GetReference() const override; | 110 OpenSSLIdentity* GetReference() const override; |
111 | 111 |
112 // Configure an SSL context object to use our key and certificate. | 112 // Configure an SSL context object to use our key and certificate. |
113 bool ConfigureIdentity(SSL_CTX* ctx); | 113 bool ConfigureIdentity(SSL_CTX* ctx); |
114 | 114 |
115 private: | 115 private: |
116 OpenSSLIdentity(OpenSSLKeyPair* key_pair, OpenSSLCertificate* certificate); | 116 OpenSSLIdentity(OpenSSLKeyPair* key_pair, OpenSSLCertificate* certificate); |
117 | 117 |
118 static OpenSSLIdentity* GenerateInternal(const SSLIdentityParams& params); | 118 static OpenSSLIdentity* GenerateInternal(const SSLIdentityParams& params); |
119 | 119 |
120 scoped_ptr<OpenSSLKeyPair> key_pair_; | 120 scoped_ptr<OpenSSLKeyPair> key_pair_; |
121 scoped_ptr<OpenSSLCertificate> certificate_; | 121 scoped_ptr<OpenSSLCertificate> certificate_; |
122 | 122 |
123 DISALLOW_COPY_AND_ASSIGN(OpenSSLIdentity); | 123 RTC_DISALLOW_COPY_AND_ASSIGN(OpenSSLIdentity); |
124 }; | 124 }; |
125 | 125 |
126 | 126 |
127 } // namespace rtc | 127 } // namespace rtc |
128 | 128 |
129 #endif // WEBRTC_BASE_OPENSSLIDENTITY_H_ | 129 #endif // WEBRTC_BASE_OPENSSLIDENTITY_H_ |
OLD | NEW |