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

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

Issue 1269843005: Added DtlsCertificate, a ref counted object owning an SSLIdentity (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Merge with master Created 5 years, 4 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
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 ssl_(NULL), ssl_ctx_(NULL), 291 ssl_(NULL), ssl_ctx_(NULL),
292 custom_verification_succeeded_(false), 292 custom_verification_succeeded_(false),
293 ssl_mode_(SSL_MODE_TLS), 293 ssl_mode_(SSL_MODE_TLS),
294 ssl_max_version_(SSL_PROTOCOL_TLS_11) { 294 ssl_max_version_(SSL_PROTOCOL_TLS_11) {
295 } 295 }
296 296
297 OpenSSLStreamAdapter::~OpenSSLStreamAdapter() { 297 OpenSSLStreamAdapter::~OpenSSLStreamAdapter() {
298 Cleanup(); 298 Cleanup();
299 } 299 }
300 300
301 void OpenSSLStreamAdapter::SetIdentity(SSLIdentity* identity) { 301 void OpenSSLStreamAdapter::SetCertificate(
302 ASSERT(!identity_); 302 const scoped_refptr<webrtc::DtlsCertificate>& certificate) {
303 identity_.reset(static_cast<OpenSSLIdentity*>(identity)); 303 ASSERT(!certificate_.get());
304 certificate_ = certificate;
304 } 305 }
305 306
306 void OpenSSLStreamAdapter::SetServerRole(SSLRole role) { 307 void OpenSSLStreamAdapter::SetServerRole(SSLRole role) {
307 role_ = role; 308 role_ = role;
308 } 309 }
309 310
310 bool OpenSSLStreamAdapter::GetPeerCertificate(SSLCertificate** cert) const { 311 bool OpenSSLStreamAdapter::GetPeerCertificate(SSLCertificate** cert) const {
311 if (!peer_certificate_) 312 if (!peer_certificate_)
312 return false; 313 return false;
313 314
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 << SSL_get_error(ssl_, ret); 871 << SSL_get_error(ssl_, ret);
871 } 872 }
872 873
873 SSL_free(ssl_); 874 SSL_free(ssl_);
874 ssl_ = NULL; 875 ssl_ = NULL;
875 } 876 }
876 if (ssl_ctx_) { 877 if (ssl_ctx_) {
877 SSL_CTX_free(ssl_ctx_); 878 SSL_CTX_free(ssl_ctx_);
878 ssl_ctx_ = NULL; 879 ssl_ctx_ = NULL;
879 } 880 }
880 identity_.reset(); 881 certificate_ = nullptr;
881 peer_certificate_.reset(); 882 peer_certificate_.reset();
882 883
883 // Clear the DTLS timer 884 // Clear the DTLS timer
884 Thread::Current()->Clear(this, MSG_TIMEOUT); 885 Thread::Current()->Clear(this, MSG_TIMEOUT);
885 } 886 }
886 887
887 888
888 void OpenSSLStreamAdapter::OnMessage(Message* msg) { 889 void OpenSSLStreamAdapter::OnMessage(Message* msg) {
889 // Process our own messages and then pass others to the superclass 890 // Process our own messages and then pass others to the superclass
890 if (MSG_TIMEOUT == msg->message_id) { 891 if (MSG_TIMEOUT == msg->message_id) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 DTLS1_VERSION : TLS1_1_VERSION); 979 DTLS1_VERSION : TLS1_1_VERSION);
979 break; 980 break;
980 case SSL_PROTOCOL_TLS_12: 981 case SSL_PROTOCOL_TLS_12:
981 default: 982 default:
982 SSL_CTX_set_max_version(ctx, ssl_mode_ == SSL_MODE_DTLS ? 983 SSL_CTX_set_max_version(ctx, ssl_mode_ == SSL_MODE_DTLS ?
983 DTLS1_2_VERSION : TLS1_2_VERSION); 984 DTLS1_2_VERSION : TLS1_2_VERSION);
984 break; 985 break;
985 } 986 }
986 #endif 987 #endif
987 988
988 if (identity_ && !identity_->ConfigureIdentity(ctx)) { 989 if (certificate_.get() &&
990 !static_cast<OpenSSLIdentity*>(certificate_->identity())
991 ->ConfigureIdentity(ctx)) {
989 SSL_CTX_free(ctx); 992 SSL_CTX_free(ctx);
990 return NULL; 993 return NULL;
991 } 994 }
992 995
993 #ifdef _DEBUG 996 #ifdef _DEBUG
994 SSL_CTX_set_info_callback(ctx, OpenSSLAdapter::SSLInfoCallback); 997 SSL_CTX_set_info_callback(ctx, OpenSSLAdapter::SSLInfoCallback);
995 #endif 998 #endif
996 999
997 int mode = SSL_VERIFY_PEER; 1000 int mode = SSL_VERIFY_PEER;
998 if (client_auth_enabled()) { 1001 if (client_auth_enabled()) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 #endif 1166 #endif
1164 } 1167 }
1165 } else { 1168 } else {
1166 return std::string(); 1169 return std::string();
1167 } 1170 }
1168 } 1171 }
1169 1172
1170 } // namespace rtc 1173 } // namespace rtc
1171 1174
1172 #endif // HAVE_OPENSSL_SSL_H 1175 #endif // HAVE_OPENSSL_SSL_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698