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

Unified Diff: talk/app/webrtc/webrtcsession.cc

Issue 1288033009: RTCCertificates added to RTCConfiguration, used by WebRtcSession/-DescriptionFactory (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed torbjorng's comment and merged 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « talk/app/webrtc/webrtcsession.h ('k') | talk/app/webrtc/webrtcsession_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/webrtcsession.cc
diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc
index be567b88b4a88ddc853833da7a329fc9e95612de..3d192c22d10b8bc9e8dcf3ba961e4cdd55860363 100644
--- a/talk/app/webrtc/webrtcsession.cc
+++ b/talk/app/webrtc/webrtcsession.cc
@@ -576,6 +576,15 @@ bool WebRtcSession::Initialize(
rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy;
SetSslMaxProtocolVersion(options.ssl_max_version);
+ // Obtain a certificate from RTCConfiguration if any were provided (optional).
+ rtc::scoped_refptr<rtc::RTCCertificate> certificate;
+ if (!rtc_configuration.certificates.empty()) {
+ // TODO(hbos,torbjorng): Decide on certificate-selection strategy instead of
+ // just picking the first one. The decision should be made based on the DTLS
+ // handshake. The DTLS negotiations need to know about all certificates.
+ certificate = rtc_configuration.certificates[0];
+ }
+
// TODO(perkj): Take |constraints| into consideration. Return false if not all
// mandatory constraints can be fulfilled. Note that |constraints|
// can be null.
@@ -584,13 +593,13 @@ bool WebRtcSession::Initialize(
if (options.disable_encryption) {
dtls_enabled_ = false;
} else {
- // Enable DTLS by default if we have a |dtls_identity_store|.
- dtls_enabled_ = (dtls_identity_store != nullptr);
+ // Enable DTLS by default if we have an identity store or a certificate.
+ dtls_enabled_ = (dtls_identity_store || certificate);
// |constraints| can override the default |dtls_enabled_| value.
if (FindConstraint(
constraints,
MediaConstraintsInterface::kEnableDtlsSrtp,
- &value, NULL)) {
+ &value, nullptr)) {
dtls_enabled_ = value;
}
}
@@ -707,15 +716,40 @@ bool WebRtcSession::Initialize(
channel_manager_->SetDefaultVideoEncoderConfig(
cricket::VideoEncoderConfig(default_codec));
- webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
- signaling_thread(),
- channel_manager_,
- mediastream_signaling_,
- dtls_identity_store.Pass(),
- this,
- id(),
- data_channel_type_,
- dtls_enabled_));
+ if (!dtls_enabled_) {
+ // Construct with DTLS disabled.
+ webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
+ signaling_thread(),
+ channel_manager_,
+ mediastream_signaling_,
+ this,
+ id(),
+ data_channel_type_));
+ } else {
+ // Construct with DTLS enabled.
+ if (!certificate) {
+ // Use the |dtls_identity_store| to generate a certificate.
+ DCHECK(dtls_identity_store);
+ webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
+ signaling_thread(),
+ channel_manager_,
+ mediastream_signaling_,
+ dtls_identity_store.Pass(),
+ this,
+ id(),
+ data_channel_type_));
+ } else {
+ // Use the already generated certificate.
+ webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
+ signaling_thread(),
+ channel_manager_,
+ mediastream_signaling_,
+ certificate,
+ this,
+ id(),
+ data_channel_type_));
+ }
+ }
webrtc_session_desc_factory_->SignalIdentityReady.connect(
this, &WebRtcSession::OnIdentityReady);
@@ -1362,8 +1396,8 @@ void WebRtcSession::OnIdentityReady(rtc::SSLIdentity* identity) {
SetIdentity(identity);
}
-bool WebRtcSession::waiting_for_identity() const {
- return webrtc_session_desc_factory_->waiting_for_identity();
+bool WebRtcSession::waiting_for_identity_for_testing() const {
+ return webrtc_session_desc_factory_->waiting_for_certificate_for_testing();
}
void WebRtcSession::SetIceConnectionState(
« no previous file with comments | « talk/app/webrtc/webrtcsession.h ('k') | talk/app/webrtc/webrtcsession_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698