OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void WebRtcIdentityRequestObserver::OnSuccess( | 91 void WebRtcIdentityRequestObserver::OnSuccess( |
92 const std::string& der_cert, const std::string& der_private_key) { | 92 const std::string& der_cert, const std::string& der_private_key) { |
93 std::string pem_cert = rtc::SSLIdentity::DerToPem( | 93 std::string pem_cert = rtc::SSLIdentity::DerToPem( |
94 rtc::kPemTypeCertificate, | 94 rtc::kPemTypeCertificate, |
95 reinterpret_cast<const unsigned char*>(der_cert.data()), | 95 reinterpret_cast<const unsigned char*>(der_cert.data()), |
96 der_cert.length()); | 96 der_cert.length()); |
97 std::string pem_key = rtc::SSLIdentity::DerToPem( | 97 std::string pem_key = rtc::SSLIdentity::DerToPem( |
98 rtc::kPemTypeRsaPrivateKey, | 98 rtc::kPemTypeRsaPrivateKey, |
99 reinterpret_cast<const unsigned char*>(der_private_key.data()), | 99 reinterpret_cast<const unsigned char*>(der_private_key.data()), |
100 der_private_key.length()); | 100 der_private_key.length()); |
101 rtc::SSLIdentity* identity = | 101 rtc::scoped_ptr<rtc::SSLIdentity> identity( |
102 rtc::SSLIdentity::FromPEMStrings(pem_key, pem_cert); | 102 rtc::SSLIdentity::FromPEMStrings(pem_key, pem_cert)); |
103 SignalIdentityReady(identity); | 103 SignalCertificateReady(rtc::RTCCertificate::Create(identity.Pass())); |
104 } | 104 } |
105 | 105 |
106 void WebRtcIdentityRequestObserver::OnSuccess( | 106 void WebRtcIdentityRequestObserver::OnSuccess( |
107 rtc::scoped_ptr<rtc::SSLIdentity> identity) { | 107 rtc::scoped_ptr<rtc::SSLIdentity> identity) { |
108 SignalIdentityReady(identity.release()); | 108 SignalCertificateReady(rtc::RTCCertificate::Create(identity.Pass())); |
109 } | 109 } |
110 | 110 |
111 // static | 111 // static |
112 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( | 112 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( |
113 const SessionDescriptionInterface* source_desc, | 113 const SessionDescriptionInterface* source_desc, |
114 SessionDescriptionInterface* dest_desc) { | 114 SessionDescriptionInterface* dest_desc) { |
115 if (!source_desc) | 115 if (!source_desc) |
116 return; | 116 return; |
117 for (size_t m = 0; m < source_desc->number_of_mediasections() && | 117 for (size_t m = 0; m < source_desc->number_of_mediasections() && |
118 m < dest_desc->number_of_mediasections(); ++m) { | 118 m < dest_desc->number_of_mediasections(); ++m) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 session, | 188 session, |
189 session_id, | 189 session_id, |
190 dct, | 190 dct, |
191 true) { | 191 true) { |
192 DCHECK(dtls_identity_store_); | 192 DCHECK(dtls_identity_store_); |
193 | 193 |
194 certificate_request_state_ = CERTIFICATE_WAITING; | 194 certificate_request_state_ = CERTIFICATE_WAITING; |
195 | 195 |
196 identity_request_observer_->SignalRequestFailed.connect( | 196 identity_request_observer_->SignalRequestFailed.connect( |
197 this, &WebRtcSessionDescriptionFactory::OnIdentityRequestFailed); | 197 this, &WebRtcSessionDescriptionFactory::OnIdentityRequestFailed); |
198 identity_request_observer_->SignalIdentityReady.connect( | 198 identity_request_observer_->SignalCertificateReady.connect( |
199 this, &WebRtcSessionDescriptionFactory::SetIdentity); | 199 this, &WebRtcSessionDescriptionFactory::SetCertificate); |
200 | 200 |
201 rtc::KeyType key_type = rtc::KT_DEFAULT; | 201 rtc::KeyType key_type = rtc::KT_DEFAULT; |
202 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; sending DTLS identity request (key " | 202 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; sending DTLS identity request (key " |
203 << "type: " << key_type << ")."; | 203 << "type: " << key_type << ")."; |
204 | 204 |
205 // Request identity. This happens asynchronously, so the caller will have a | 205 // Request identity. This happens asynchronously, so the caller will have a |
206 // chance to connect to SignalIdentityReady. | 206 // chance to connect to SignalIdentityReady. |
207 dtls_identity_store_->RequestIdentity(key_type, identity_request_observer_); | 207 dtls_identity_store_->RequestIdentity(key_type, identity_request_observer_); |
208 } | 208 } |
209 | 209 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 static_cast<CreateSessionDescriptionMsg*>(msg->pdata); | 380 static_cast<CreateSessionDescriptionMsg*>(msg->pdata); |
381 param->observer->OnFailure(param->error); | 381 param->observer->OnFailure(param->error); |
382 delete param; | 382 delete param; |
383 break; | 383 break; |
384 } | 384 } |
385 case MSG_USE_CONSTRUCTOR_CERTIFICATE: { | 385 case MSG_USE_CONSTRUCTOR_CERTIFICATE: { |
386 rtc::ScopedRefMessageData<rtc::RTCCertificate>* param = | 386 rtc::ScopedRefMessageData<rtc::RTCCertificate>* param = |
387 static_cast<rtc::ScopedRefMessageData<rtc::RTCCertificate>*>( | 387 static_cast<rtc::ScopedRefMessageData<rtc::RTCCertificate>*>( |
388 msg->pdata); | 388 msg->pdata); |
389 LOG(LS_INFO) << "Using certificate supplied to the constructor."; | 389 LOG(LS_INFO) << "Using certificate supplied to the constructor."; |
390 // TODO(hbos): Pass around scoped_refptr<RTCCertificate> instead of | 390 SetCertificate(param->data()); |
391 // SSLIdentity* (then there will be no need to do GetReference here). | |
392 SetIdentity(param->data()->identity()->GetReference()); | |
393 delete param; | 391 delete param; |
394 break; | 392 break; |
395 } | 393 } |
396 default: | 394 default: |
397 ASSERT(false); | 395 ASSERT(false); |
398 break; | 396 break; |
399 } | 397 } |
400 } | 398 } |
401 | 399 |
402 void WebRtcSessionDescriptionFactory::InternalCreateOffer( | 400 void WebRtcSessionDescriptionFactory::InternalCreateOffer( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 507 |
510 void WebRtcSessionDescriptionFactory::OnIdentityRequestFailed(int error) { | 508 void WebRtcSessionDescriptionFactory::OnIdentityRequestFailed(int error) { |
511 ASSERT(signaling_thread_->IsCurrent()); | 509 ASSERT(signaling_thread_->IsCurrent()); |
512 | 510 |
513 LOG(LS_ERROR) << "Async identity request failed: error = " << error; | 511 LOG(LS_ERROR) << "Async identity request failed: error = " << error; |
514 certificate_request_state_ = CERTIFICATE_FAILED; | 512 certificate_request_state_ = CERTIFICATE_FAILED; |
515 | 513 |
516 FailPendingRequests(kFailedDueToIdentityFailed); | 514 FailPendingRequests(kFailedDueToIdentityFailed); |
517 } | 515 } |
518 | 516 |
519 void WebRtcSessionDescriptionFactory::SetIdentity( | 517 void WebRtcSessionDescriptionFactory::SetCertificate( |
520 rtc::SSLIdentity* identity) { | 518 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { |
521 LOG(LS_VERBOSE) << "Setting new identity"; | 519 DCHECK(certificate); |
| 520 LOG(LS_VERBOSE) << "Setting new certificate"; |
522 | 521 |
523 certificate_request_state_ = CERTIFICATE_SUCCEEDED; | 522 certificate_request_state_ = CERTIFICATE_SUCCEEDED; |
524 SignalIdentityReady(identity); | 523 SignalCertificateReady(certificate); |
525 | 524 |
526 transport_desc_factory_.set_identity(identity); | 525 // TODO(hbos): set_certificate |
| 526 transport_desc_factory_.set_identity(certificate->identity()); |
527 transport_desc_factory_.set_secure(cricket::SEC_ENABLED); | 527 transport_desc_factory_.set_secure(cricket::SEC_ENABLED); |
528 | 528 |
529 while (!create_session_description_requests_.empty()) { | 529 while (!create_session_description_requests_.empty()) { |
530 if (create_session_description_requests_.front().type == | 530 if (create_session_description_requests_.front().type == |
531 CreateSessionDescriptionRequest::kOffer) { | 531 CreateSessionDescriptionRequest::kOffer) { |
532 InternalCreateOffer(create_session_description_requests_.front()); | 532 InternalCreateOffer(create_session_description_requests_.front()); |
533 } else { | 533 } else { |
534 InternalCreateAnswer(create_session_description_requests_.front()); | 534 InternalCreateAnswer(create_session_description_requests_.front()); |
535 } | 535 } |
536 create_session_description_requests_.pop(); | 536 create_session_description_requests_.pop(); |
537 } | 537 } |
538 } | 538 } |
539 } // namespace webrtc | 539 } // namespace webrtc |
OLD | NEW |