OLD | NEW |
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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // creation, we have the negotiation state saved until a new | 394 // creation, we have the negotiation state saved until a new |
395 // negotiation happens. | 395 // negotiation happens. |
396 for (const auto& kv : channels_) { | 396 for (const auto& kv : channels_) { |
397 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) { | 397 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) { |
398 return false; | 398 return false; |
399 } | 399 } |
400 } | 400 } |
401 return true; | 401 return true; |
402 } | 402 } |
403 | 403 |
| 404 bool Transport::VerifyCertificateFingerprint( |
| 405 const rtc::RTCCertificate* certificate, |
| 406 const rtc::SSLFingerprint* fingerprint, |
| 407 std::string* error_desc) const { |
| 408 if (!fingerprint) { |
| 409 return BadTransportDescription("No fingerprint.", error_desc); |
| 410 } |
| 411 if (!certificate) { |
| 412 return BadTransportDescription( |
| 413 "Fingerprint provided but no identity available.", error_desc); |
| 414 } |
| 415 rtc::scoped_ptr<rtc::SSLFingerprint> fp_tmp(rtc::SSLFingerprint::Create( |
| 416 fingerprint->algorithm, certificate->identity())); |
| 417 ASSERT(fp_tmp.get() != NULL); |
| 418 if (*fp_tmp == *fingerprint) { |
| 419 return true; |
| 420 } |
| 421 std::ostringstream desc; |
| 422 desc << "Local fingerprint does not match identity. Expected: "; |
| 423 desc << fp_tmp->ToString(); |
| 424 desc << " Got: " << fingerprint->ToString(); |
| 425 return BadTransportDescription(desc.str(), error_desc); |
| 426 } |
| 427 |
| 428 bool Transport::NegotiateRole(ContentAction local_role, |
| 429 rtc::SSLRole* ssl_role, |
| 430 std::string* error_desc) const { |
| 431 RTC_DCHECK(ssl_role); |
| 432 if (!local_description() || !remote_description()) { |
| 433 const std::string msg = |
| 434 "Local and Remote description must be set before " |
| 435 "transport descriptions are negotiated"; |
| 436 return BadTransportDescription(msg, error_desc); |
| 437 } |
| 438 |
| 439 // From RFC 4145, section-4.1, The following are the values that the |
| 440 // 'setup' attribute can take in an offer/answer exchange: |
| 441 // Offer Answer |
| 442 // ________________ |
| 443 // active passive / holdconn |
| 444 // passive active / holdconn |
| 445 // actpass active / passive / holdconn |
| 446 // holdconn holdconn |
| 447 // |
| 448 // Set the role that is most conformant with RFC 5763, Section 5, bullet 1 |
| 449 // The endpoint MUST use the setup attribute defined in [RFC4145]. |
| 450 // The endpoint that is the offerer MUST use the setup attribute |
| 451 // value of setup:actpass and be prepared to receive a client_hello |
| 452 // before it receives the answer. The answerer MUST use either a |
| 453 // setup attribute value of setup:active or setup:passive. Note that |
| 454 // if the answerer uses setup:passive, then the DTLS handshake will |
| 455 // not begin until the answerer is received, which adds additional |
| 456 // latency. setup:active allows the answer and the DTLS handshake to |
| 457 // occur in parallel. Thus, setup:active is RECOMMENDED. Whichever |
| 458 // party is active MUST initiate a DTLS handshake by sending a |
| 459 // ClientHello over each flow (host/port quartet). |
| 460 // IOW - actpass and passive modes should be treated as server and |
| 461 // active as client. |
| 462 ConnectionRole local_connection_role = local_description()->connection_role; |
| 463 ConnectionRole remote_connection_role = remote_description()->connection_role; |
| 464 |
| 465 bool is_remote_server = false; |
| 466 if (local_role == CA_OFFER) { |
| 467 if (local_connection_role != CONNECTIONROLE_ACTPASS) { |
| 468 return BadTransportDescription( |
| 469 "Offerer must use actpass value for setup attribute.", error_desc); |
| 470 } |
| 471 |
| 472 if (remote_connection_role == CONNECTIONROLE_ACTIVE || |
| 473 remote_connection_role == CONNECTIONROLE_PASSIVE || |
| 474 remote_connection_role == CONNECTIONROLE_NONE) { |
| 475 is_remote_server = (remote_connection_role == CONNECTIONROLE_PASSIVE); |
| 476 } else { |
| 477 const std::string msg = |
| 478 "Answerer must use either active or passive value " |
| 479 "for setup attribute."; |
| 480 return BadTransportDescription(msg, error_desc); |
| 481 } |
| 482 // If remote is NONE or ACTIVE it will act as client. |
| 483 } else { |
| 484 if (remote_connection_role != CONNECTIONROLE_ACTPASS && |
| 485 remote_connection_role != CONNECTIONROLE_NONE) { |
| 486 return BadTransportDescription( |
| 487 "Offerer must use actpass value for setup attribute.", error_desc); |
| 488 } |
| 489 |
| 490 if (local_connection_role == CONNECTIONROLE_ACTIVE || |
| 491 local_connection_role == CONNECTIONROLE_PASSIVE) { |
| 492 is_remote_server = (local_connection_role == CONNECTIONROLE_ACTIVE); |
| 493 } else { |
| 494 const std::string msg = |
| 495 "Answerer must use either active or passive value " |
| 496 "for setup attribute."; |
| 497 return BadTransportDescription(msg, error_desc); |
| 498 } |
| 499 |
| 500 // If local is passive, local will act as server. |
| 501 } |
| 502 |
| 503 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER; |
| 504 return true; |
| 505 } |
| 506 |
404 } // namespace cricket | 507 } // namespace cricket |
OLD | NEW |