OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 19 matching lines...) Expand all Loading... |
30 explicit FakeSSLCertificate(const std::vector<std::string>& certs) | 30 explicit FakeSSLCertificate(const std::vector<std::string>& certs) |
31 : data_(certs.front()), | 31 : data_(certs.front()), |
32 digest_algorithm_(DIGEST_SHA_1), | 32 digest_algorithm_(DIGEST_SHA_1), |
33 expiration_time_(-1) { | 33 expiration_time_(-1) { |
34 std::vector<std::string>::const_iterator it; | 34 std::vector<std::string>::const_iterator it; |
35 // Skip certs[0]. | 35 // Skip certs[0]. |
36 for (it = certs.begin() + 1; it != certs.end(); ++it) { | 36 for (it = certs.begin() + 1; it != certs.end(); ++it) { |
37 certs_.push_back(FakeSSLCertificate(*it)); | 37 certs_.push_back(FakeSSLCertificate(*it)); |
38 } | 38 } |
39 } | 39 } |
40 virtual FakeSSLCertificate* GetReference() const { | 40 FakeSSLCertificate* GetReference() const override { |
41 return new FakeSSLCertificate(*this); | 41 return new FakeSSLCertificate(*this); |
42 } | 42 } |
43 virtual std::string ToPEMString() const { | 43 std::string ToPEMString() const override { |
44 return data_; | 44 return data_; |
45 } | 45 } |
46 virtual void ToDER(Buffer* der_buffer) const { | 46 void ToDER(Buffer* der_buffer) const override { |
47 std::string der_string; | 47 std::string der_string; |
48 VERIFY(SSLIdentity::PemToDer(kPemTypeCertificate, data_, &der_string)); | 48 VERIFY(SSLIdentity::PemToDer(kPemTypeCertificate, data_, &der_string)); |
49 der_buffer->SetData(der_string.c_str(), der_string.size()); | 49 der_buffer->SetData(der_string.c_str(), der_string.size()); |
50 } | 50 } |
51 int64_t CertificateExpirationTime() const override { | 51 int64_t CertificateExpirationTime() const override { |
52 return expiration_time_; | 52 return expiration_time_; |
53 } | 53 } |
54 void SetCertificateExpirationTime(int64_t expiration_time) { | 54 void SetCertificateExpirationTime(int64_t expiration_time) { |
55 expiration_time_ = expiration_time; | 55 expiration_time_ = expiration_time; |
56 } | 56 } |
57 void set_digest_algorithm(const std::string& algorithm) { | 57 void set_digest_algorithm(const std::string& algorithm) { |
58 digest_algorithm_ = algorithm; | 58 digest_algorithm_ = algorithm; |
59 } | 59 } |
60 virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const { | 60 bool GetSignatureDigestAlgorithm(std::string* algorithm) const override { |
61 *algorithm = digest_algorithm_; | 61 *algorithm = digest_algorithm_; |
62 return true; | 62 return true; |
63 } | 63 } |
64 virtual bool ComputeDigest(const std::string& algorithm, | 64 bool ComputeDigest(const std::string& algorithm, |
65 unsigned char* digest, | 65 unsigned char* digest, |
66 size_t size, | 66 size_t size, |
67 size_t* length) const { | 67 size_t* length) const override { |
68 *length = rtc::ComputeDigest(algorithm, data_.c_str(), data_.size(), | 68 *length = rtc::ComputeDigest(algorithm, data_.c_str(), data_.size(), |
69 digest, size); | 69 digest, size); |
70 return (*length != 0); | 70 return (*length != 0); |
71 } | 71 } |
72 virtual std::unique_ptr<SSLCertChain> GetChain() const { | 72 std::unique_ptr<SSLCertChain> GetChain() const override { |
73 if (certs_.empty()) | 73 if (certs_.empty()) |
74 return nullptr; | 74 return nullptr; |
75 std::vector<SSLCertificate*> new_certs(certs_.size()); | 75 std::vector<SSLCertificate*> new_certs(certs_.size()); |
76 std::transform(certs_.begin(), certs_.end(), new_certs.begin(), DupCert); | 76 std::transform(certs_.begin(), certs_.end(), new_certs.begin(), DupCert); |
77 std::unique_ptr<SSLCertChain> chain(new SSLCertChain(new_certs)); | 77 std::unique_ptr<SSLCertChain> chain(new SSLCertChain(new_certs)); |
78 std::for_each(new_certs.begin(), new_certs.end(), DeleteCert); | 78 std::for_each(new_certs.begin(), new_certs.end(), DeleteCert); |
79 return chain; | 79 return chain; |
80 } | 80 } |
81 | 81 |
82 private: | 82 private: |
(...skipping 16 matching lines...) Expand all Loading... |
99 return new FakeSSLIdentity(*this); | 99 return new FakeSSLIdentity(*this); |
100 } | 100 } |
101 virtual const FakeSSLCertificate& certificate() const { return cert_; } | 101 virtual const FakeSSLCertificate& certificate() const { return cert_; } |
102 private: | 102 private: |
103 FakeSSLCertificate cert_; | 103 FakeSSLCertificate cert_; |
104 }; | 104 }; |
105 | 105 |
106 } // namespace rtc | 106 } // namespace rtc |
107 | 107 |
108 #endif // WEBRTC_BASE_FAKESSLIDENTITY_H_ | 108 #endif // WEBRTC_BASE_FAKESSLIDENTITY_H_ |
OLD | NEW |