OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/http/transport_security_state.h" | 5 #include "net/http/transport_security_state.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 state.SetRequireCTDelegate(&default_require_ct_delegate); | 1950 state.SetRequireCTDelegate(&default_require_ct_delegate); |
1951 EXPECT_EQ(original_status, | 1951 EXPECT_EQ(original_status, |
1952 state.ShouldRequireCT("www.example.com", cert.get(), hashes)); | 1952 state.ShouldRequireCT("www.example.com", cert.get(), hashes)); |
1953 | 1953 |
1954 state.SetRequireCTDelegate(nullptr); | 1954 state.SetRequireCTDelegate(nullptr); |
1955 EXPECT_EQ(original_status, | 1955 EXPECT_EQ(original_status, |
1956 state.ShouldRequireCT("www.example.com", cert.get(), hashes)); | 1956 state.ShouldRequireCT("www.example.com", cert.get(), hashes)); |
1957 } | 1957 } |
1958 } | 1958 } |
1959 | 1959 |
| 1960 // Tests that Certificate Transparency is required for Symantec-issued |
| 1961 // certificates, unless the certificate was issued prior to 1 June 2016 |
| 1962 // or the issuing CA is whitelisted as independently operated. |
| 1963 TEST_F(TransportSecurityStateTest, RequireCTForSymantec) { |
| 1964 // Test certificates before and after the 1 June 2016 deadline. |
| 1965 scoped_refptr<X509Certificate> before_cert = |
| 1966 ImportCertFromFile(GetTestCertsDirectory(), "pre_june_2016.pem"); |
| 1967 ASSERT_TRUE(before_cert); |
| 1968 scoped_refptr<X509Certificate> after_cert = |
| 1969 ImportCertFromFile(GetTestCertsDirectory(), "post_june_2016.pem"); |
| 1970 ASSERT_TRUE(after_cert); |
| 1971 |
| 1972 SHA256HashValue symantec_hash_value = { |
| 1973 {0xb2, 0xde, 0xf5, 0x36, 0x2a, 0xd3, 0xfa, 0xcd, 0x04, 0xbd, 0x29, |
| 1974 0x04, 0x7a, 0x43, 0x84, 0x4f, 0x76, 0x70, 0x34, 0xea, 0x48, 0x92, |
| 1975 0xf8, 0x0e, 0x56, 0xbe, 0xe6, 0x90, 0x24, 0x3e, 0x25, 0x02}}; |
| 1976 SHA256HashValue google_hash_value = { |
| 1977 {0xec, 0x72, 0x29, 0x69, 0xcb, 0x64, 0x20, 0x0a, 0xb6, 0x63, 0x8f, |
| 1978 0x68, 0xac, 0x53, 0x8e, 0x40, 0xab, 0xab, 0x5b, 0x19, 0xa6, 0x48, |
| 1979 0x56, 0x61, 0x04, 0x2a, 0x10, 0x61, 0xc4, 0x61, 0x27, 0x76}}; |
| 1980 |
| 1981 TransportSecurityState state; |
| 1982 |
| 1983 HashValueVector hashes; |
| 1984 hashes.push_back(HashValue(symantec_hash_value)); |
| 1985 |
| 1986 // Certificates issued by Symantec prior to 1 June 2016 should not |
| 1987 // be required to be disclosed via CT. |
| 1988 EXPECT_FALSE( |
| 1989 state.ShouldRequireCT("www.example.com", before_cert.get(), hashes)); |
| 1990 |
| 1991 // ... but certificates issued after 1 June 2016 are required to be... |
| 1992 EXPECT_TRUE( |
| 1993 state.ShouldRequireCT("www.example.com", after_cert.get(), hashes)); |
| 1994 |
| 1995 // ... unless they were issued by an excluded intermediate. |
| 1996 hashes.push_back(HashValue(google_hash_value)); |
| 1997 EXPECT_FALSE( |
| 1998 state.ShouldRequireCT("www.example.com", before_cert.get(), hashes)); |
| 1999 EXPECT_FALSE( |
| 2000 state.ShouldRequireCT("www.example.com", after_cert.get(), hashes)); |
| 2001 |
| 2002 // And other certificates should remain unaffected. |
| 2003 SHA256HashValue unrelated_hash_value = {{0x01, 0x02}}; |
| 2004 HashValueVector unrelated_hashes; |
| 2005 unrelated_hashes.push_back(HashValue(unrelated_hash_value)); |
| 2006 |
| 2007 EXPECT_FALSE(state.ShouldRequireCT("www.example.com", before_cert.get(), |
| 2008 unrelated_hashes)); |
| 2009 EXPECT_FALSE(state.ShouldRequireCT("www.example.com", after_cert.get(), |
| 2010 unrelated_hashes)); |
| 2011 } |
| 2012 |
1960 } // namespace net | 2013 } // namespace net |
OLD | NEW |