| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/rtc_certificate.h" | 5 #include "content/renderer/media/rtc_certificate.h" |
| 6 | 6 |
| 7 #include <vector> |
| 8 |
| 7 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "third_party/webrtc/base/sslidentity.h" |
| 8 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 9 | 12 |
| 10 namespace content { | 13 namespace content { |
| 11 | 14 |
| 12 RTCCertificate::RTCCertificate( | 15 RTCCertificate::RTCCertificate( |
| 13 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) | 16 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) |
| 14 : certificate_(certificate) { | 17 : certificate_(certificate) { |
| 15 DCHECK(certificate_); | 18 DCHECK(certificate_); |
| 16 } | 19 } |
| 17 | 20 |
| 18 RTCCertificate::~RTCCertificate() { | 21 RTCCertificate::~RTCCertificate() { |
| 19 } | 22 } |
| 20 | 23 |
| 21 std::unique_ptr<blink::WebRTCCertificate> RTCCertificate::ShallowCopy() const { | 24 std::unique_ptr<blink::WebRTCCertificate> RTCCertificate::ShallowCopy() const { |
| 22 return base::WrapUnique(new RTCCertificate(certificate_)); | 25 return base::WrapUnique(new RTCCertificate(certificate_)); |
| 23 } | 26 } |
| 24 | 27 |
| 25 uint64_t RTCCertificate::Expires() const { | 28 uint64_t RTCCertificate::Expires() const { |
| 26 return certificate_->Expires(); | 29 return certificate_->Expires(); |
| 27 } | 30 } |
| 28 | 31 |
| 32 blink::WebVector<blink::WebRTCDtlsFingerprint> RTCCertificate::Fingerprints() |
| 33 const { |
| 34 std::vector<blink::WebRTCDtlsFingerprint> fingerprints; |
| 35 std::unique_ptr<rtc::SSLCertificateStats> first_certificate_stats = |
| 36 certificate_->identity()->certificate().GetStats(); |
| 37 for (rtc::SSLCertificateStats* certificate_stats = |
| 38 first_certificate_stats.get(); |
| 39 certificate_stats; certificate_stats = certificate_stats->issuer.get()) { |
| 40 fingerprints.push_back(blink::WebRTCDtlsFingerprint( |
| 41 blink::WebString::FromUTF8(certificate_stats->fingerprint_algorithm), |
| 42 blink::WebString::FromUTF8(certificate_stats->fingerprint))); |
| 43 } |
| 44 return blink::WebVector<blink::WebRTCDtlsFingerprint>(fingerprints); |
| 45 } |
| 46 |
| 29 blink::WebRTCCertificatePEM RTCCertificate::ToPEM() const { | 47 blink::WebRTCCertificatePEM RTCCertificate::ToPEM() const { |
| 30 rtc::RTCCertificatePEM pem = certificate_->ToPEM(); | 48 rtc::RTCCertificatePEM pem = certificate_->ToPEM(); |
| 31 return blink::WebRTCCertificatePEM( | 49 return blink::WebRTCCertificatePEM( |
| 32 blink::WebString::FromUTF8(pem.private_key()), | 50 blink::WebString::FromUTF8(pem.private_key()), |
| 33 blink::WebString::FromUTF8(pem.certificate())); | 51 blink::WebString::FromUTF8(pem.certificate())); |
| 34 } | 52 } |
| 35 | 53 |
| 36 bool RTCCertificate::Equals(const blink::WebRTCCertificate& other) const { | 54 bool RTCCertificate::Equals(const blink::WebRTCCertificate& other) const { |
| 37 return *certificate_ == | 55 return *certificate_ == |
| 38 *static_cast<const RTCCertificate&>(other).certificate_; | 56 *static_cast<const RTCCertificate&>(other).certificate_; |
| 39 } | 57 } |
| 40 | 58 |
| 41 const rtc::scoped_refptr<rtc::RTCCertificate>& | 59 const rtc::scoped_refptr<rtc::RTCCertificate>& |
| 42 RTCCertificate::rtcCertificate() const { | 60 RTCCertificate::rtcCertificate() const { |
| 43 return certificate_; | 61 return certificate_; |
| 44 } | 62 } |
| 45 | 63 |
| 46 } // namespace content | 64 } // namespace content |
| OLD | NEW |