OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/cert/ct_objects_extractor.h" | 5 #include "net/cert/ct_objects_extractor.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "net/cert/ct_log_verifier.h" | 8 #include "net/cert/ct_log_verifier.h" |
9 #include "net/cert/ct_serialization.h" | 9 #include "net/cert/ct_serialization.h" |
10 #include "net/cert/signed_certificate_timestamp.h" | 10 #include "net/cert/signed_certificate_timestamp.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 ASSERT_TRUE(test_cert_); | 33 ASSERT_TRUE(test_cert_); |
34 | 34 |
35 log_ = CTLogVerifier::Create(ct::GetTestPublicKey(), "testlog", | 35 log_ = CTLogVerifier::Create(ct::GetTestPublicKey(), "testlog", |
36 "https://ct.example.com", "dns.example.com"); | 36 "https://ct.example.com", "dns.example.com"); |
37 ASSERT_TRUE(log_); | 37 ASSERT_TRUE(log_); |
38 } | 38 } |
39 | 39 |
40 void ExtractEmbeddedSCT(scoped_refptr<X509Certificate> cert, | 40 void ExtractEmbeddedSCT(scoped_refptr<X509Certificate> cert, |
41 scoped_refptr<SignedCertificateTimestamp>* sct) { | 41 scoped_refptr<SignedCertificateTimestamp>* sct) { |
42 std::string sct_list; | 42 std::string sct_list; |
43 EXPECT_TRUE(ExtractEmbeddedSCTList(cert->os_cert_handle(), &sct_list)); | 43 ASSERT_TRUE(ExtractEmbeddedSCTList(cert->os_cert_handle(), &sct_list)); |
44 | 44 |
45 std::vector<base::StringPiece> parsed_scts; | 45 std::vector<base::StringPiece> parsed_scts; |
46 base::StringPiece sct_list_sp(sct_list); | |
47 // Make sure the SCT list can be decoded properly | 46 // Make sure the SCT list can be decoded properly |
48 EXPECT_TRUE(DecodeSCTList(sct_list_sp, &parsed_scts)); | 47 ASSERT_TRUE(DecodeSCTList(sct_list, &parsed_scts)); |
| 48 ASSERT_EQ(1u, parsed_scts.size()); |
49 EXPECT_TRUE(DecodeSignedCertificateTimestamp(&parsed_scts[0], sct)); | 49 EXPECT_TRUE(DecodeSignedCertificateTimestamp(&parsed_scts[0], sct)); |
50 } | 50 } |
51 | 51 |
52 protected: | 52 protected: |
53 CertificateList precert_chain_; | 53 CertificateList precert_chain_; |
54 scoped_refptr<X509Certificate> test_cert_; | 54 scoped_refptr<X509Certificate> test_cert_; |
55 scoped_refptr<const CTLogVerifier> log_; | 55 scoped_refptr<const CTLogVerifier> log_; |
56 }; | 56 }; |
57 | 57 |
58 // Test that an SCT can be extracted and the extracted SCT contains the | 58 // Test that an SCT can be extracted and the extracted SCT contains the |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 std::string extracted_sct_list; | 177 std::string extracted_sct_list; |
178 // Use test_cert_ for issuer - it is not the correct issuer of |subject_cert|. | 178 // Use test_cert_ for issuer - it is not the correct issuer of |subject_cert|. |
179 EXPECT_FALSE(ct::ExtractSCTListFromOCSPResponse( | 179 EXPECT_FALSE(ct::ExtractSCTListFromOCSPResponse( |
180 test_cert_->os_cert_handle(), subject_cert->serial_number(), | 180 test_cert_->os_cert_handle(), subject_cert->serial_number(), |
181 ocsp_response, &extracted_sct_list)); | 181 ocsp_response, &extracted_sct_list)); |
182 } | 182 } |
183 | 183 |
184 } // namespace ct | 184 } // namespace ct |
185 | 185 |
186 } // namespace net | 186 } // namespace net |
OLD | NEW |