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 bool SSLIdentity::PemToDer(const std::string& pem_type, | 38 bool SSLIdentity::PemToDer(const std::string& pem_type, |
43 const std::string& pem_string, | 39 const std::string& pem_string, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 132 |
137 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { | 133 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { |
138 return OpenSSLIdentity::GenerateForTest(params); | 134 return OpenSSLIdentity::GenerateForTest(params); |
139 } | 135 } |
140 | 136 |
141 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, | 137 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, |
142 const std::string& certificate) { | 138 const std::string& certificate) { |
143 return OpenSSLIdentity::FromPEMStrings(private_key, certificate); | 139 return OpenSSLIdentity::FromPEMStrings(private_key, certificate); |
144 } | 140 } |
145 | 141 |
146 #elif SSL_USE_NSS // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL | 142 #else // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL |
147 | |
148 SSLCertificate* SSLCertificate::FromPEMString(const std::string& pem_string) { | |
149 return NSSCertificate::FromPEMString(pem_string); | |
150 } | |
151 | |
152 SSLIdentity* SSLIdentity::Generate(const std::string& common_name, | |
153 KeyType key_type) { | |
154 return NSSIdentity::Generate(common_name, key_type); | |
155 } | |
156 | |
157 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { | |
158 return NSSIdentity::GenerateForTest(params); | |
159 } | |
160 | |
161 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, | |
162 const std::string& certificate) { | |
163 return NSSIdentity::FromPEMStrings(private_key, certificate); | |
164 } | |
165 | |
166 #else // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL && !SSL_USE_NSS | |
167 | 143 |
168 #error "No SSL implementation" | 144 #error "No SSL implementation" |
169 | 145 |
170 #endif // SSL_USE_SCHANNEL | 146 #endif // SSL_USE_SCHANNEL |
171 | 147 |
172 } // namespace rtc | 148 } // namespace rtc |
OLD | NEW |