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 |
11 // Handling of certificates and keypairs for SSLStreamAdapter's peer mode. | 11 // Handling of certificates and keypairs for SSLStreamAdapter's peer mode. |
12 #if HAVE_CONFIG_H | 12 #if HAVE_CONFIG_H |
13 #include "config.h" | 13 #include "config.h" |
14 #endif // HAVE_CONFIG_H | 14 #endif // HAVE_CONFIG_H |
15 | 15 |
16 #include "webrtc/base/sslidentity.h" | 16 #include "webrtc/base/sslidentity.h" |
17 | 17 |
18 #include <string> | 18 #include <string> |
19 | 19 |
20 #include "webrtc/base/base64.h" | 20 #include "webrtc/base/base64.h" |
21 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
22 #include "webrtc/base/sslconfig.h" | 22 #include "webrtc/base/sslconfig.h" |
23 | 23 |
24 #if SSL_USE_SCHANNEL | 24 #if SSL_USE_SCHANNEL |
25 | 25 |
26 #elif SSL_USE_OPENSSL // !SSL_USE_SCHANNEL | 26 #elif SSL_USE_OPENSSL // !SSL_USE_SCHANNEL |
27 | 27 |
28 #include "webrtc/base/opensslidentity.h" | 28 #include "webrtc/base/opensslidentity.h" |
29 | 29 |
30 #elif SSL_USE_NSS // !SSL_USE_SCHANNEL && !SSL_USE_OPENSSL | |
31 | |
32 #include "webrtc/base/nssidentity.h" | |
33 | |
34 #endif // SSL_USE_SCHANNEL | 30 #endif // SSL_USE_SCHANNEL |
35 | 31 |
36 namespace rtc { | 32 namespace rtc { |
37 | 33 |
38 const char kPemTypeCertificate[] = "CERTIFICATE"; | 34 const char kPemTypeCertificate[] = "CERTIFICATE"; |
39 const char kPemTypeRsaPrivateKey[] = "RSA PRIVATE KEY"; | 35 const char kPemTypeRsaPrivateKey[] = "RSA PRIVATE KEY"; |
40 const char kPemTypeEcPrivateKey[] = "EC PRIVATE KEY"; | 36 const char kPemTypeEcPrivateKey[] = "EC PRIVATE KEY"; |
41 | 37 |
42 KeyType IntKeyTypeFamilyToKeyType(int key_type_family) { | 38 KeyType IntKeyTypeFamilyToKeyType(int key_type_family) { |
43 return static_cast<KeyType>(key_type_family); | 39 return static_cast<KeyType>(key_type_family); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 136 |
141 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { | 137 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { |
142 return OpenSSLIdentity::GenerateForTest(params); | 138 return OpenSSLIdentity::GenerateForTest(params); |
143 } | 139 } |
144 | 140 |
145 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, | 141 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, |
146 const std::string& certificate) { | 142 const std::string& certificate) { |
147 return OpenSSLIdentity::FromPEMStrings(private_key, certificate); | 143 return OpenSSLIdentity::FromPEMStrings(private_key, certificate); |
148 } | 144 } |
149 | 145 |
150 #elif SSL_USE_NSS // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL | 146 #else // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL |
151 | |
152 SSLCertificate* SSLCertificate::FromPEMString(const std::string& pem_string) { | |
153 return NSSCertificate::FromPEMString(pem_string); | |
154 } | |
155 | |
156 SSLIdentity* SSLIdentity::Generate(const std::string& common_name, | |
157 KeyType key_type) { | |
158 return NSSIdentity::Generate(common_name, key_type); | |
159 } | |
160 | |
161 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { | |
162 return NSSIdentity::GenerateForTest(params); | |
163 } | |
164 | |
165 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, | |
166 const std::string& certificate) { | |
167 return NSSIdentity::FromPEMStrings(private_key, certificate); | |
168 } | |
169 | |
170 #else // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL && !SSL_USE_NSS | |
171 | 147 |
172 #error "No SSL implementation" | 148 #error "No SSL implementation" |
173 | 149 |
174 #endif // SSL_USE_SCHANNEL | 150 #endif // SSL_USE_SCHANNEL |
175 | 151 |
176 } // namespace rtc | 152 } // namespace rtc |
OLD | NEW |