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 #if HAVE_OPENSSL_SSL_H | 11 #if HAVE_OPENSSL_SSL_H |
12 | 12 |
13 #include "webrtc/base/opensslidentity.h" | 13 #include "webrtc/base/opensslidentity.h" |
14 | 14 |
| 15 #include <memory> |
| 16 |
15 // Must be included first before openssl headers. | 17 // Must be included first before openssl headers. |
16 #include "webrtc/base/win32.h" // NOLINT | 18 #include "webrtc/base/win32.h" // NOLINT |
17 | 19 |
18 #include <openssl/bio.h> | 20 #include <openssl/bio.h> |
19 #include <openssl/err.h> | 21 #include <openssl/err.h> |
20 #include <openssl/pem.h> | 22 #include <openssl/pem.h> |
21 #include <openssl/bn.h> | 23 #include <openssl/bn.h> |
22 #include <openssl/rsa.h> | 24 #include <openssl/rsa.h> |
23 #include <openssl/crypto.h> | 25 #include <openssl/crypto.h> |
24 | 26 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 default: | 275 default: |
274 // Unknown algorithm. There are several unhandled options that are less | 276 // Unknown algorithm. There are several unhandled options that are less |
275 // common and more complex. | 277 // common and more complex. |
276 LOG(LS_ERROR) << "Unknown signature algorithm NID: " << nid; | 278 LOG(LS_ERROR) << "Unknown signature algorithm NID: " << nid; |
277 algorithm->clear(); | 279 algorithm->clear(); |
278 return false; | 280 return false; |
279 } | 281 } |
280 return true; | 282 return true; |
281 } | 283 } |
282 | 284 |
283 rtc::scoped_ptr<SSLCertChain> OpenSSLCertificate::GetChain() const { | 285 std::unique_ptr<SSLCertChain> OpenSSLCertificate::GetChain() const { |
284 // Chains are not yet supported when using OpenSSL. | 286 // Chains are not yet supported when using OpenSSL. |
285 // OpenSSLStreamAdapter::SSLVerifyCallback currently requires the remote | 287 // OpenSSLStreamAdapter::SSLVerifyCallback currently requires the remote |
286 // certificate to be self-signed. | 288 // certificate to be self-signed. |
287 return nullptr; | 289 return nullptr; |
288 } | 290 } |
289 | 291 |
290 bool OpenSSLCertificate::ComputeDigest(const std::string& algorithm, | 292 bool OpenSSLCertificate::ComputeDigest(const std::string& algorithm, |
291 unsigned char* digest, | 293 unsigned char* digest, |
292 size_t size, | 294 size_t size, |
293 size_t* length) const { | 295 size_t* length) const { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 } | 425 } |
424 | 426 |
425 OpenSSLIdentity* OpenSSLIdentity::GenerateForTest( | 427 OpenSSLIdentity* OpenSSLIdentity::GenerateForTest( |
426 const SSLIdentityParams& params) { | 428 const SSLIdentityParams& params) { |
427 return GenerateInternal(params); | 429 return GenerateInternal(params); |
428 } | 430 } |
429 | 431 |
430 SSLIdentity* OpenSSLIdentity::FromPEMStrings( | 432 SSLIdentity* OpenSSLIdentity::FromPEMStrings( |
431 const std::string& private_key, | 433 const std::string& private_key, |
432 const std::string& certificate) { | 434 const std::string& certificate) { |
433 scoped_ptr<OpenSSLCertificate> cert( | 435 std::unique_ptr<OpenSSLCertificate> cert( |
434 OpenSSLCertificate::FromPEMString(certificate)); | 436 OpenSSLCertificate::FromPEMString(certificate)); |
435 if (!cert) { | 437 if (!cert) { |
436 LOG(LS_ERROR) << "Failed to create OpenSSLCertificate from PEM string."; | 438 LOG(LS_ERROR) << "Failed to create OpenSSLCertificate from PEM string."; |
437 return NULL; | 439 return NULL; |
438 } | 440 } |
439 | 441 |
440 BIO* bio = BIO_new_mem_buf(const_cast<char*>(private_key.c_str()), -1); | 442 BIO* bio = BIO_new_mem_buf(const_cast<char*>(private_key.c_str()), -1); |
441 if (!bio) { | 443 if (!bio) { |
442 LOG(LS_ERROR) << "Failed to create a new BIO buffer."; | 444 LOG(LS_ERROR) << "Failed to create a new BIO buffer."; |
443 return NULL; | 445 return NULL; |
(...skipping 27 matching lines...) Expand all Loading... |
471 SSL_CTX_use_PrivateKey(ctx, key_pair_->pkey()) != 1) { | 473 SSL_CTX_use_PrivateKey(ctx, key_pair_->pkey()) != 1) { |
472 LogSSLErrors("Configuring key and certificate"); | 474 LogSSLErrors("Configuring key and certificate"); |
473 return false; | 475 return false; |
474 } | 476 } |
475 return true; | 477 return true; |
476 } | 478 } |
477 | 479 |
478 } // namespace rtc | 480 } // namespace rtc |
479 | 481 |
480 #endif // HAVE_OPENSSL_SSL_H | 482 #endif // HAVE_OPENSSL_SSL_H |
OLD | NEW |