| 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 |
| 30 #endif // SSL_USE_SCHANNEL | 34 #endif // SSL_USE_SCHANNEL |
| 31 | 35 |
| 32 namespace rtc { | 36 namespace rtc { |
| 33 | 37 |
| 34 const char kPemTypeCertificate[] = "CERTIFICATE"; | 38 const char kPemTypeCertificate[] = "CERTIFICATE"; |
| 35 const char kPemTypeRsaPrivateKey[] = "RSA PRIVATE KEY"; | 39 const char kPemTypeRsaPrivateKey[] = "RSA PRIVATE KEY"; |
| 36 const char kPemTypeEcPrivateKey[] = "EC PRIVATE KEY"; | 40 const char kPemTypeEcPrivateKey[] = "EC PRIVATE KEY"; |
| 37 | 41 |
| 38 bool SSLIdentity::PemToDer(const std::string& pem_type, | 42 bool SSLIdentity::PemToDer(const std::string& pem_type, |
| 39 const std::string& pem_string, | 43 const std::string& pem_string, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 136 |
| 133 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { | 137 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { |
| 134 return OpenSSLIdentity::GenerateForTest(params); | 138 return OpenSSLIdentity::GenerateForTest(params); |
| 135 } | 139 } |
| 136 | 140 |
| 137 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, | 141 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, |
| 138 const std::string& certificate) { | 142 const std::string& certificate) { |
| 139 return OpenSSLIdentity::FromPEMStrings(private_key, certificate); | 143 return OpenSSLIdentity::FromPEMStrings(private_key, certificate); |
| 140 } | 144 } |
| 141 | 145 |
| 142 #else // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL | 146 #elif SSL_USE_NSS // !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 |
| 143 | 167 |
| 144 #error "No SSL implementation" | 168 #error "No SSL implementation" |
| 145 | 169 |
| 146 #endif // SSL_USE_SCHANNEL | 170 #endif // SSL_USE_SCHANNEL |
| 147 | 171 |
| 148 } // namespace rtc | 172 } // namespace rtc |
| OLD | NEW |