| 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_OPENSSL |
| 25 | |
| 26 #elif SSL_USE_OPENSSL // !SSL_USE_SCHANNEL | |
| 27 | 25 |
| 28 #include "webrtc/base/opensslidentity.h" | 26 #include "webrtc/base/opensslidentity.h" |
| 29 | 27 |
| 30 #endif // SSL_USE_SCHANNEL | 28 #endif // SSL_USE_OPENSSL |
| 31 | 29 |
| 32 namespace rtc { | 30 namespace rtc { |
| 33 | 31 |
| 34 const char kPemTypeCertificate[] = "CERTIFICATE"; | 32 const char kPemTypeCertificate[] = "CERTIFICATE"; |
| 35 const char kPemTypeRsaPrivateKey[] = "RSA PRIVATE KEY"; | 33 const char kPemTypeRsaPrivateKey[] = "RSA PRIVATE KEY"; |
| 36 const char kPemTypeEcPrivateKey[] = "EC PRIVATE KEY"; | 34 const char kPemTypeEcPrivateKey[] = "EC PRIVATE KEY"; |
| 37 | 35 |
| 38 KeyType IntKeyTypeFamilyToKeyType(int key_type_family) { | 36 KeyType IntKeyTypeFamilyToKeyType(int key_type_family) { |
| 39 return static_cast<KeyType>(key_type_family); | 37 return static_cast<KeyType>(key_type_family); |
| 40 } | 38 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 94 } |
| 97 | 95 |
| 98 SSLCertChain::SSLCertChain(const SSLCertificate* cert) { | 96 SSLCertChain::SSLCertChain(const SSLCertificate* cert) { |
| 99 certs_.push_back(cert->GetReference()); | 97 certs_.push_back(cert->GetReference()); |
| 100 } | 98 } |
| 101 | 99 |
| 102 SSLCertChain::~SSLCertChain() { | 100 SSLCertChain::~SSLCertChain() { |
| 103 std::for_each(certs_.begin(), certs_.end(), DeleteCert); | 101 std::for_each(certs_.begin(), certs_.end(), DeleteCert); |
| 104 } | 102 } |
| 105 | 103 |
| 106 #if SSL_USE_SCHANNEL | 104 #if SSL_USE_OPENSSL |
| 107 | |
| 108 SSLCertificate* SSLCertificate::FromPEMString(const std::string& pem_string) { | |
| 109 return NULL; | |
| 110 } | |
| 111 | |
| 112 SSLIdentity* SSLIdentity::Generate(const std::string& common_name, | |
| 113 KeyType key_type) { | |
| 114 return NULL; | |
| 115 } | |
| 116 | |
| 117 SSLIdentity* GenerateForTest(const SSLIdentityParams& params) { | |
| 118 return NULL; | |
| 119 } | |
| 120 | |
| 121 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, | |
| 122 const std::string& certificate) { | |
| 123 return NULL; | |
| 124 } | |
| 125 | |
| 126 #elif SSL_USE_OPENSSL // !SSL_USE_SCHANNEL | |
| 127 | 105 |
| 128 SSLCertificate* SSLCertificate::FromPEMString(const std::string& pem_string) { | 106 SSLCertificate* SSLCertificate::FromPEMString(const std::string& pem_string) { |
| 129 return OpenSSLCertificate::FromPEMString(pem_string); | 107 return OpenSSLCertificate::FromPEMString(pem_string); |
| 130 } | 108 } |
| 131 | 109 |
| 132 SSLIdentity* SSLIdentity::Generate(const std::string& common_name, | 110 SSLIdentity* SSLIdentity::Generate(const std::string& common_name, |
| 133 KeyType key_type) { | 111 KeyType key_type) { |
| 134 return OpenSSLIdentity::Generate(common_name, key_type); | 112 return OpenSSLIdentity::Generate(common_name, key_type); |
| 135 } | 113 } |
| 136 | 114 |
| 137 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { | 115 SSLIdentity* SSLIdentity::GenerateForTest(const SSLIdentityParams& params) { |
| 138 return OpenSSLIdentity::GenerateForTest(params); | 116 return OpenSSLIdentity::GenerateForTest(params); |
| 139 } | 117 } |
| 140 | 118 |
| 141 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, | 119 SSLIdentity* SSLIdentity::FromPEMStrings(const std::string& private_key, |
| 142 const std::string& certificate) { | 120 const std::string& certificate) { |
| 143 return OpenSSLIdentity::FromPEMStrings(private_key, certificate); | 121 return OpenSSLIdentity::FromPEMStrings(private_key, certificate); |
| 144 } | 122 } |
| 145 | 123 |
| 146 #else // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL | 124 #else // !SSL_USE_OPENSSL |
| 147 | 125 |
| 148 #error "No SSL implementation" | 126 #error "No SSL implementation" |
| 149 | 127 |
| 150 #endif // SSL_USE_SCHANNEL | 128 #endif // SSL_USE_OPENSSL |
| 151 | 129 |
| 152 } // namespace rtc | 130 } // namespace rtc |
| OLD | NEW |