Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: webrtc/base/opensslidentity.cc

Issue 1828773003: Revert of Remove code interfacing legacy openssl. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/openssladapter.cc ('k') | webrtc/base/opensslstreamadapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 OpenSSLKeyPair::~OpenSSLKeyPair() { 167 OpenSSLKeyPair::~OpenSSLKeyPair() {
168 EVP_PKEY_free(pkey_); 168 EVP_PKEY_free(pkey_);
169 } 169 }
170 170
171 OpenSSLKeyPair* OpenSSLKeyPair::GetReference() { 171 OpenSSLKeyPair* OpenSSLKeyPair::GetReference() {
172 AddReference(); 172 AddReference();
173 return new OpenSSLKeyPair(pkey_); 173 return new OpenSSLKeyPair(pkey_);
174 } 174 }
175 175
176 void OpenSSLKeyPair::AddReference() { 176 void OpenSSLKeyPair::AddReference() {
177 #if defined(OPENSSL_IS_BORINGSSL)
177 EVP_PKEY_up_ref(pkey_); 178 EVP_PKEY_up_ref(pkey_);
179 #else
180 CRYPTO_add(&pkey_->references, 1, CRYPTO_LOCK_EVP_PKEY);
181 #endif
178 } 182 }
179 183
180 #if !defined(NDEBUG) 184 #if !defined(NDEBUG)
181 // Print a certificate to the log, for debugging. 185 // Print a certificate to the log, for debugging.
182 static void PrintCert(X509* x509) { 186 static void PrintCert(X509* x509) {
183 BIO* temp_memory_bio = BIO_new(BIO_s_mem()); 187 BIO* temp_memory_bio = BIO_new(BIO_s_mem());
184 if (!temp_memory_bio) { 188 if (!temp_memory_bio) {
185 LOG_F(LS_ERROR) << "Failed to allocate temporary memory bio"; 189 LOG_F(LS_ERROR) << "Failed to allocate temporary memory bio";
186 return; 190 return;
187 } 191 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 FATAL() << "unreachable code"; 354 FATAL() << "unreachable code";
351 } 355 }
352 char* data; 356 char* data;
353 size_t length = BIO_get_mem_data(bio, &data); 357 size_t length = BIO_get_mem_data(bio, &data);
354 der_buffer->SetData(data, length); 358 der_buffer->SetData(data, length);
355 BIO_free(bio); 359 BIO_free(bio);
356 } 360 }
357 361
358 void OpenSSLCertificate::AddReference() const { 362 void OpenSSLCertificate::AddReference() const {
359 ASSERT(x509_ != NULL); 363 ASSERT(x509_ != NULL);
364 #if defined(OPENSSL_IS_BORINGSSL)
360 X509_up_ref(x509_); 365 X509_up_ref(x509_);
366 #else
367 CRYPTO_add(&x509_->references, 1, CRYPTO_LOCK_X509);
368 #endif
361 } 369 }
362 370
363 // Documented in sslidentity.h. 371 // Documented in sslidentity.h.
364 int64_t OpenSSLCertificate::CertificateExpirationTime() const { 372 int64_t OpenSSLCertificate::CertificateExpirationTime() const {
365 ASN1_TIME* expire_time = X509_get_notAfter(x509_); 373 ASN1_TIME* expire_time = X509_get_notAfter(x509_);
366 bool long_format; 374 bool long_format;
367 375
368 if (expire_time->type == V_ASN1_UTCTIME) { 376 if (expire_time->type == V_ASN1_UTCTIME) {
369 long_format = false; 377 long_format = false;
370 } else if (expire_time->type == V_ASN1_GENERALIZEDTIME) { 378 } else if (expire_time->type == V_ASN1_GENERALIZEDTIME) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 SSL_CTX_use_PrivateKey(ctx, key_pair_->pkey()) != 1) { 469 SSL_CTX_use_PrivateKey(ctx, key_pair_->pkey()) != 1) {
462 LogSSLErrors("Configuring key and certificate"); 470 LogSSLErrors("Configuring key and certificate");
463 return false; 471 return false;
464 } 472 }
465 return true; 473 return true;
466 } 474 }
467 475
468 } // namespace rtc 476 } // namespace rtc
469 477
470 #endif // HAVE_OPENSSL_SSL_H 478 #endif // HAVE_OPENSSL_SSL_H
OLDNEW
« no previous file with comments | « webrtc/base/openssladapter.cc ('k') | webrtc/base/opensslstreamadapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698