Chromium Code Reviews| Index: talk/app/webrtc/webrtcsession.cc |
| diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc |
| index fde45104d61ddfafee2791b1e297d164ab6425ac..10e8da4dd6c4a662c219032e78b41d2fdc53d26d 100644 |
| --- a/talk/app/webrtc/webrtcsession.cc |
| +++ b/talk/app/webrtc/webrtcsession.cc |
| @@ -576,6 +576,13 @@ 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): How to decide which certificate to use? |
| + 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 +591,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 +714,39 @@ 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. |
|
tommi
2015/08/24 11:26:32
can you add a DCHECK(dtls_identity_store)
hbos
2015/08/24 12:01:34
Done.
|
| + 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); |
| @@ -1355,8 +1386,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( |