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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
10 #include "crypto/sha2.h" | 10 #include "crypto/sha2.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 | 497 |
498 TEST_F(HttpSecurityHeadersTest, ValidPKPHeadersSHA256) { | 498 TEST_F(HttpSecurityHeadersTest, ValidPKPHeadersSHA256) { |
499 TestValidPKPHeaders(HASH_VALUE_SHA256); | 499 TestValidPKPHeaders(HASH_VALUE_SHA256); |
500 } | 500 } |
501 | 501 |
502 TEST_F(HttpSecurityHeadersTest, UpdateDynamicPKPOnly) { | 502 TEST_F(HttpSecurityHeadersTest, UpdateDynamicPKPOnly) { |
503 TransportSecurityState state; | 503 TransportSecurityState state; |
504 TransportSecurityState::DomainState static_domain_state; | 504 TransportSecurityState::DomainState static_domain_state; |
505 | 505 |
506 // docs.google.com has preloaded pins. | 506 // docs.google.com has preloaded pins. |
507 const bool sni_enabled = true; | |
508 std::string domain = "docs.google.com"; | 507 std::string domain = "docs.google.com"; |
509 state.enable_static_pins_ = true; | 508 state.enable_static_pins_ = true; |
510 EXPECT_TRUE( | 509 EXPECT_TRUE( |
511 state.GetStaticDomainState(domain, sni_enabled, &static_domain_state)); | 510 state.GetStaticDomainState(domain, &static_domain_state)); |
512 EXPECT_GT(static_domain_state.pkp.spki_hashes.size(), 1UL); | 511 EXPECT_GT(static_domain_state.pkp.spki_hashes.size(), 1UL); |
513 HashValueVector saved_hashes = static_domain_state.pkp.spki_hashes; | 512 HashValueVector saved_hashes = static_domain_state.pkp.spki_hashes; |
514 | 513 |
515 // Add a header, which should only update the dynamic state. | 514 // Add a header, which should only update the dynamic state. |
516 HashValue good_hash = GetTestHashValue(1, HASH_VALUE_SHA1); | 515 HashValue good_hash = GetTestHashValue(1, HASH_VALUE_SHA1); |
517 HashValue backup_hash = GetTestHashValue(2, HASH_VALUE_SHA1); | 516 HashValue backup_hash = GetTestHashValue(2, HASH_VALUE_SHA1); |
518 std::string good_pin = GetTestPin(1, HASH_VALUE_SHA1); | 517 std::string good_pin = GetTestPin(1, HASH_VALUE_SHA1); |
519 std::string backup_pin = GetTestPin(2, HASH_VALUE_SHA1); | 518 std::string backup_pin = GetTestPin(2, HASH_VALUE_SHA1); |
520 std::string header = "max-age = 10000; " + good_pin + "; " + backup_pin; | 519 std::string header = "max-age = 10000; " + good_pin + "; " + backup_pin; |
521 | 520 |
522 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. | 521 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. |
523 SSLInfo ssl_info; | 522 SSLInfo ssl_info; |
524 ssl_info.public_key_hashes.push_back(good_hash); | 523 ssl_info.public_key_hashes.push_back(good_hash); |
525 ssl_info.public_key_hashes.push_back(saved_hashes[0]); | 524 ssl_info.public_key_hashes.push_back(saved_hashes[0]); |
526 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); | 525 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); |
527 | 526 |
528 // Expect the static state to remain unchanged. | 527 // Expect the static state to remain unchanged. |
529 TransportSecurityState::DomainState new_static_domain_state; | 528 TransportSecurityState::DomainState new_static_domain_state; |
530 EXPECT_TRUE(state.GetStaticDomainState( | 529 EXPECT_TRUE(state.GetStaticDomainState( |
531 domain, sni_enabled, &new_static_domain_state)); | 530 domain, &new_static_domain_state)); |
532 for (size_t i = 0; i < saved_hashes.size(); ++i) { | 531 for (size_t i = 0; i < saved_hashes.size(); ++i) { |
533 EXPECT_TRUE(HashValuesEqual(saved_hashes[i])( | 532 EXPECT_TRUE(HashValuesEqual(saved_hashes[i])( |
534 new_static_domain_state.pkp.spki_hashes[i])); | 533 new_static_domain_state.pkp.spki_hashes[i])); |
535 } | 534 } |
536 | 535 |
537 // Expect the dynamic state to reflect the header. | 536 // Expect the dynamic state to reflect the header. |
538 TransportSecurityState::DomainState dynamic_domain_state; | 537 TransportSecurityState::DomainState dynamic_domain_state; |
539 EXPECT_TRUE(state.GetDynamicDomainState(domain, &dynamic_domain_state)); | 538 EXPECT_TRUE(state.GetDynamicDomainState(domain, &dynamic_domain_state)); |
540 EXPECT_EQ(2UL, dynamic_domain_state.pkp.spki_hashes.size()); | 539 EXPECT_EQ(2UL, dynamic_domain_state.pkp.spki_hashes.size()); |
541 | 540 |
542 HashValueVector::const_iterator hash = | 541 HashValueVector::const_iterator hash = |
543 std::find_if(dynamic_domain_state.pkp.spki_hashes.begin(), | 542 std::find_if(dynamic_domain_state.pkp.spki_hashes.begin(), |
544 dynamic_domain_state.pkp.spki_hashes.end(), | 543 dynamic_domain_state.pkp.spki_hashes.end(), |
545 HashValuesEqual(good_hash)); | 544 HashValuesEqual(good_hash)); |
546 EXPECT_NE(dynamic_domain_state.pkp.spki_hashes.end(), hash); | 545 EXPECT_NE(dynamic_domain_state.pkp.spki_hashes.end(), hash); |
547 | 546 |
548 hash = std::find_if(dynamic_domain_state.pkp.spki_hashes.begin(), | 547 hash = std::find_if(dynamic_domain_state.pkp.spki_hashes.begin(), |
549 dynamic_domain_state.pkp.spki_hashes.end(), | 548 dynamic_domain_state.pkp.spki_hashes.end(), |
550 HashValuesEqual(backup_hash)); | 549 HashValuesEqual(backup_hash)); |
551 EXPECT_NE(dynamic_domain_state.pkp.spki_hashes.end(), hash); | 550 EXPECT_NE(dynamic_domain_state.pkp.spki_hashes.end(), hash); |
552 | 551 |
553 // Expect the overall state to reflect the header, too. | 552 // Expect the overall state to reflect the header, too. |
554 EXPECT_TRUE(state.HasPublicKeyPins(domain, sni_enabled)); | 553 EXPECT_TRUE(state.HasPublicKeyPins(domain)); |
555 HashValueVector hashes; | 554 HashValueVector hashes; |
556 hashes.push_back(good_hash); | 555 hashes.push_back(good_hash); |
557 std::string failure_log; | 556 std::string failure_log; |
558 const bool is_issued_by_known_root = true; | 557 const bool is_issued_by_known_root = true; |
559 EXPECT_TRUE(state.CheckPublicKeyPins( | 558 EXPECT_TRUE(state.CheckPublicKeyPins( |
560 domain, sni_enabled, is_issued_by_known_root, hashes, &failure_log)); | 559 domain, is_issued_by_known_root, hashes, &failure_log)); |
561 | 560 |
562 TransportSecurityState::DomainState new_dynamic_domain_state; | 561 TransportSecurityState::DomainState new_dynamic_domain_state; |
563 EXPECT_TRUE(state.GetDynamicDomainState(domain, &new_dynamic_domain_state)); | 562 EXPECT_TRUE(state.GetDynamicDomainState(domain, &new_dynamic_domain_state)); |
564 EXPECT_EQ(2UL, new_dynamic_domain_state.pkp.spki_hashes.size()); | 563 EXPECT_EQ(2UL, new_dynamic_domain_state.pkp.spki_hashes.size()); |
565 | 564 |
566 hash = std::find_if(new_dynamic_domain_state.pkp.spki_hashes.begin(), | 565 hash = std::find_if(new_dynamic_domain_state.pkp.spki_hashes.begin(), |
567 new_dynamic_domain_state.pkp.spki_hashes.end(), | 566 new_dynamic_domain_state.pkp.spki_hashes.end(), |
568 HashValuesEqual(good_hash)); | 567 HashValuesEqual(good_hash)); |
569 EXPECT_NE(new_dynamic_domain_state.pkp.spki_hashes.end(), hash); | 568 EXPECT_NE(new_dynamic_domain_state.pkp.spki_hashes.end(), hash); |
570 | 569 |
571 hash = std::find_if(new_dynamic_domain_state.pkp.spki_hashes.begin(), | 570 hash = std::find_if(new_dynamic_domain_state.pkp.spki_hashes.begin(), |
572 new_dynamic_domain_state.pkp.spki_hashes.end(), | 571 new_dynamic_domain_state.pkp.spki_hashes.end(), |
573 HashValuesEqual(backup_hash)); | 572 HashValuesEqual(backup_hash)); |
574 EXPECT_NE(new_dynamic_domain_state.pkp.spki_hashes.end(), hash); | 573 EXPECT_NE(new_dynamic_domain_state.pkp.spki_hashes.end(), hash); |
575 } | 574 } |
576 | 575 |
577 // Failing on win_chromium_rel. crbug.com/375538 | 576 // Failing on win_chromium_rel. crbug.com/375538 |
578 #if defined(OS_WIN) | 577 #if defined(OS_WIN) |
579 #define MAYBE_UpdateDynamicPKPMaxAge0 DISABLED_UpdateDynamicPKPMaxAge0 | 578 #define MAYBE_UpdateDynamicPKPMaxAge0 DISABLED_UpdateDynamicPKPMaxAge0 |
580 #else | 579 #else |
581 #define MAYBE_UpdateDynamicPKPMaxAge0 UpdateDynamicPKPMaxAge0 | 580 #define MAYBE_UpdateDynamicPKPMaxAge0 UpdateDynamicPKPMaxAge0 |
582 #endif | 581 #endif |
583 TEST_F(HttpSecurityHeadersTest, MAYBE_UpdateDynamicPKPMaxAge0) { | 582 TEST_F(HttpSecurityHeadersTest, MAYBE_UpdateDynamicPKPMaxAge0) { |
584 TransportSecurityState state; | 583 TransportSecurityState state; |
585 TransportSecurityState::DomainState static_domain_state; | 584 TransportSecurityState::DomainState static_domain_state; |
586 | 585 |
587 // docs.google.com has preloaded pins. | 586 // docs.google.com has preloaded pins. |
588 const bool sni_enabled = true; | |
589 std::string domain = "docs.google.com"; | 587 std::string domain = "docs.google.com"; |
590 state.enable_static_pins_ = true; | 588 state.enable_static_pins_ = true; |
591 ASSERT_TRUE( | 589 ASSERT_TRUE( |
592 state.GetStaticDomainState(domain, sni_enabled, &static_domain_state)); | 590 state.GetStaticDomainState(domain, &static_domain_state)); |
593 EXPECT_GT(static_domain_state.pkp.spki_hashes.size(), 1UL); | 591 EXPECT_GT(static_domain_state.pkp.spki_hashes.size(), 1UL); |
594 HashValueVector saved_hashes = static_domain_state.pkp.spki_hashes; | 592 HashValueVector saved_hashes = static_domain_state.pkp.spki_hashes; |
595 | 593 |
596 // Add a header, which should only update the dynamic state. | 594 // Add a header, which should only update the dynamic state. |
597 HashValue good_hash = GetTestHashValue(1, HASH_VALUE_SHA1); | 595 HashValue good_hash = GetTestHashValue(1, HASH_VALUE_SHA1); |
598 std::string good_pin = GetTestPin(1, HASH_VALUE_SHA1); | 596 std::string good_pin = GetTestPin(1, HASH_VALUE_SHA1); |
599 std::string backup_pin = GetTestPin(2, HASH_VALUE_SHA1); | 597 std::string backup_pin = GetTestPin(2, HASH_VALUE_SHA1); |
600 std::string header = "max-age = 10000; " + good_pin + "; " + backup_pin; | 598 std::string header = "max-age = 10000; " + good_pin + "; " + backup_pin; |
601 | 599 |
602 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. | 600 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. |
603 SSLInfo ssl_info; | 601 SSLInfo ssl_info; |
604 ssl_info.public_key_hashes.push_back(good_hash); | 602 ssl_info.public_key_hashes.push_back(good_hash); |
605 ssl_info.public_key_hashes.push_back(saved_hashes[0]); | 603 ssl_info.public_key_hashes.push_back(saved_hashes[0]); |
606 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); | 604 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); |
607 | 605 |
608 // Expect the static state to remain unchanged. | 606 // Expect the static state to remain unchanged. |
609 TransportSecurityState::DomainState new_static_domain_state; | 607 TransportSecurityState::DomainState new_static_domain_state; |
610 EXPECT_TRUE(state.GetStaticDomainState( | 608 EXPECT_TRUE(state.GetStaticDomainState( |
611 domain, sni_enabled, &new_static_domain_state)); | 609 domain, &new_static_domain_state)); |
612 EXPECT_EQ(saved_hashes.size(), | 610 EXPECT_EQ(saved_hashes.size(), |
613 new_static_domain_state.pkp.spki_hashes.size()); | 611 new_static_domain_state.pkp.spki_hashes.size()); |
614 for (size_t i = 0; i < saved_hashes.size(); ++i) { | 612 for (size_t i = 0; i < saved_hashes.size(); ++i) { |
615 EXPECT_TRUE(HashValuesEqual(saved_hashes[i])( | 613 EXPECT_TRUE(HashValuesEqual(saved_hashes[i])( |
616 new_static_domain_state.pkp.spki_hashes[i])); | 614 new_static_domain_state.pkp.spki_hashes[i])); |
617 } | 615 } |
618 | 616 |
619 // Expect the dynamic state to have pins. | 617 // Expect the dynamic state to have pins. |
620 TransportSecurityState::DomainState new_dynamic_domain_state; | 618 TransportSecurityState::DomainState new_dynamic_domain_state; |
621 EXPECT_TRUE(state.GetDynamicDomainState(domain, &new_dynamic_domain_state)); | 619 EXPECT_TRUE(state.GetDynamicDomainState(domain, &new_dynamic_domain_state)); |
622 EXPECT_EQ(2UL, new_dynamic_domain_state.pkp.spki_hashes.size()); | 620 EXPECT_EQ(2UL, new_dynamic_domain_state.pkp.spki_hashes.size()); |
623 EXPECT_TRUE(new_dynamic_domain_state.HasPublicKeyPins()); | 621 EXPECT_TRUE(new_dynamic_domain_state.HasPublicKeyPins()); |
624 | 622 |
625 // Now set another header with max-age=0, and check that the pins are | 623 // Now set another header with max-age=0, and check that the pins are |
626 // cleared in the dynamic state only. | 624 // cleared in the dynamic state only. |
627 header = "max-age = 0; " + good_pin + "; " + backup_pin; | 625 header = "max-age = 0; " + good_pin + "; " + backup_pin; |
628 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); | 626 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); |
629 | 627 |
630 // Expect the static state to remain unchanged. | 628 // Expect the static state to remain unchanged. |
631 TransportSecurityState::DomainState new_static_domain_state2; | 629 TransportSecurityState::DomainState new_static_domain_state2; |
632 EXPECT_TRUE(state.GetStaticDomainState( | 630 EXPECT_TRUE(state.GetStaticDomainState( |
633 domain, sni_enabled, &new_static_domain_state2)); | 631 domain, &new_static_domain_state2)); |
634 EXPECT_EQ(saved_hashes.size(), | 632 EXPECT_EQ(saved_hashes.size(), |
635 new_static_domain_state2.pkp.spki_hashes.size()); | 633 new_static_domain_state2.pkp.spki_hashes.size()); |
636 for (size_t i = 0; i < saved_hashes.size(); ++i) { | 634 for (size_t i = 0; i < saved_hashes.size(); ++i) { |
637 EXPECT_TRUE(HashValuesEqual(saved_hashes[i])( | 635 EXPECT_TRUE(HashValuesEqual(saved_hashes[i])( |
638 new_static_domain_state2.pkp.spki_hashes[i])); | 636 new_static_domain_state2.pkp.spki_hashes[i])); |
639 } | 637 } |
640 | 638 |
641 // Expect the dynamic pins to be gone. | 639 // Expect the dynamic pins to be gone. |
642 TransportSecurityState::DomainState new_dynamic_domain_state2; | 640 TransportSecurityState::DomainState new_dynamic_domain_state2; |
643 EXPECT_FALSE(state.GetDynamicDomainState(domain, &new_dynamic_domain_state2)); | 641 EXPECT_FALSE(state.GetDynamicDomainState(domain, &new_dynamic_domain_state2)); |
644 | 642 |
645 // Expect the exact-matching static policy to continue to apply, even | 643 // Expect the exact-matching static policy to continue to apply, even |
646 // though dynamic policy has been removed. (This policy may change in the | 644 // though dynamic policy has been removed. (This policy may change in the |
647 // future, in which case this test must be updated.) | 645 // future, in which case this test must be updated.) |
648 EXPECT_TRUE(state.HasPublicKeyPins(domain, true)); | 646 EXPECT_TRUE(state.HasPublicKeyPins(domain)); |
649 EXPECT_TRUE(state.ShouldSSLErrorsBeFatal(domain, true)); | 647 EXPECT_TRUE(state.ShouldSSLErrorsBeFatal(domain)); |
650 std::string failure_log; | 648 std::string failure_log; |
651 // Damage the hashes to cause a pin validation failure. | 649 // Damage the hashes to cause a pin validation failure. |
652 new_static_domain_state2.pkp.spki_hashes[0].data()[0] ^= 0x80; | 650 new_static_domain_state2.pkp.spki_hashes[0].data()[0] ^= 0x80; |
653 new_static_domain_state2.pkp.spki_hashes[1].data()[0] ^= 0x80; | 651 new_static_domain_state2.pkp.spki_hashes[1].data()[0] ^= 0x80; |
654 const bool is_issued_by_known_root = true; | 652 const bool is_issued_by_known_root = true; |
655 EXPECT_FALSE( | 653 EXPECT_FALSE( |
656 state.CheckPublicKeyPins(domain, | 654 state.CheckPublicKeyPins(domain, |
657 true, | |
658 is_issued_by_known_root, | 655 is_issued_by_known_root, |
659 new_static_domain_state2.pkp.spki_hashes, | 656 new_static_domain_state2.pkp.spki_hashes, |
660 &failure_log)); | 657 &failure_log)); |
661 EXPECT_NE(0UL, failure_log.length()); | 658 EXPECT_NE(0UL, failure_log.length()); |
662 } | 659 } |
663 #undef MAYBE_UpdateDynamicPKPMaxAge0 | 660 #undef MAYBE_UpdateDynamicPKPMaxAge0 |
664 | 661 |
665 // Tests that when a static HSTS and a static HPKP entry are present, adding a | 662 // Tests that when a static HSTS and a static HPKP entry are present, adding a |
666 // dynamic HSTS header does not clobber the static HPKP entry. Further, adding a | 663 // dynamic HSTS header does not clobber the static HPKP entry. Further, adding a |
667 // dynamic HPKP entry could not affect the HSTS entry for the site. | 664 // dynamic HPKP entry could not affect the HSTS entry for the site. |
668 TEST_F(HttpSecurityHeadersTest, NoClobberPins) { | 665 TEST_F(HttpSecurityHeadersTest, NoClobberPins) { |
669 TransportSecurityState state; | 666 TransportSecurityState state; |
670 TransportSecurityState::DomainState domain_state; | 667 TransportSecurityState::DomainState domain_state; |
671 | 668 |
672 // accounts.google.com has preloaded pins. | 669 // accounts.google.com has preloaded pins. |
673 std::string domain = "accounts.google.com"; | 670 std::string domain = "accounts.google.com"; |
674 state.enable_static_pins_ = true; | 671 state.enable_static_pins_ = true; |
675 | 672 |
676 // Retrieve the DomainState as it is by default, including its known good | 673 // Retrieve the DomainState as it is by default, including its known good |
677 // pins. | 674 // pins. |
678 const bool sni_enabled = true; | 675 EXPECT_TRUE(state.GetStaticDomainState(domain, &domain_state)); |
679 EXPECT_TRUE(state.GetStaticDomainState(domain, sni_enabled, &domain_state)); | |
680 HashValueVector saved_hashes = domain_state.pkp.spki_hashes; | 676 HashValueVector saved_hashes = domain_state.pkp.spki_hashes; |
681 EXPECT_TRUE(domain_state.ShouldUpgradeToSSL()); | 677 EXPECT_TRUE(domain_state.ShouldUpgradeToSSL()); |
682 EXPECT_TRUE(domain_state.HasPublicKeyPins()); | 678 EXPECT_TRUE(domain_state.HasPublicKeyPins()); |
683 EXPECT_TRUE(state.ShouldUpgradeToSSL(domain, sni_enabled)); | 679 EXPECT_TRUE(state.ShouldUpgradeToSSL(domain)); |
684 EXPECT_TRUE(state.HasPublicKeyPins(domain, sni_enabled)); | 680 EXPECT_TRUE(state.HasPublicKeyPins(domain)); |
685 | 681 |
686 // Add a dynamic HSTS header. CheckPublicKeyPins should still pass when given | 682 // Add a dynamic HSTS header. CheckPublicKeyPins should still pass when given |
687 // the original |saved_hashes|, indicating that the static PKP data is still | 683 // the original |saved_hashes|, indicating that the static PKP data is still |
688 // configured for the domain. | 684 // configured for the domain. |
689 EXPECT_TRUE(state.AddHSTSHeader(domain, "includesubdomains; max-age=10000")); | 685 EXPECT_TRUE(state.AddHSTSHeader(domain, "includesubdomains; max-age=10000")); |
690 EXPECT_TRUE(state.ShouldUpgradeToSSL(domain, sni_enabled)); | 686 EXPECT_TRUE(state.ShouldUpgradeToSSL(domain)); |
691 std::string failure_log; | 687 std::string failure_log; |
692 const bool is_issued_by_known_root = true; | 688 const bool is_issued_by_known_root = true; |
693 EXPECT_TRUE(state.CheckPublicKeyPins(domain, | 689 EXPECT_TRUE(state.CheckPublicKeyPins(domain, |
694 sni_enabled, | |
695 is_issued_by_known_root, | 690 is_issued_by_known_root, |
696 saved_hashes, | 691 saved_hashes, |
697 &failure_log)); | 692 &failure_log)); |
698 | 693 |
699 // Add an HPKP header, which should only update the dynamic state. | 694 // Add an HPKP header, which should only update the dynamic state. |
700 HashValue good_hash = GetTestHashValue(1, HASH_VALUE_SHA1); | 695 HashValue good_hash = GetTestHashValue(1, HASH_VALUE_SHA1); |
701 std::string good_pin = GetTestPin(1, HASH_VALUE_SHA1); | 696 std::string good_pin = GetTestPin(1, HASH_VALUE_SHA1); |
702 std::string backup_pin = GetTestPin(2, HASH_VALUE_SHA1); | 697 std::string backup_pin = GetTestPin(2, HASH_VALUE_SHA1); |
703 std::string header = "max-age = 10000; " + good_pin + "; " + backup_pin; | 698 std::string header = "max-age = 10000; " + good_pin + "; " + backup_pin; |
704 | 699 |
705 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. | 700 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. |
706 SSLInfo ssl_info; | 701 SSLInfo ssl_info; |
707 ssl_info.public_key_hashes.push_back(good_hash); | 702 ssl_info.public_key_hashes.push_back(good_hash); |
708 ssl_info.public_key_hashes.push_back(saved_hashes[0]); | 703 ssl_info.public_key_hashes.push_back(saved_hashes[0]); |
709 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); | 704 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); |
710 | 705 |
711 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); | 706 EXPECT_TRUE(state.AddHPKPHeader(domain, header, ssl_info)); |
712 // HSTS should still be configured for this domain. | 707 // HSTS should still be configured for this domain. |
713 EXPECT_TRUE(domain_state.ShouldUpgradeToSSL()); | 708 EXPECT_TRUE(domain_state.ShouldUpgradeToSSL()); |
714 EXPECT_TRUE(state.ShouldUpgradeToSSL(domain, sni_enabled)); | 709 EXPECT_TRUE(state.ShouldUpgradeToSSL(domain)); |
715 // The dynamic pins, which do not match |saved_hashes|, should take | 710 // The dynamic pins, which do not match |saved_hashes|, should take |
716 // precedence over the static pins and cause the check to fail. | 711 // precedence over the static pins and cause the check to fail. |
717 EXPECT_FALSE(state.CheckPublicKeyPins(domain, | 712 EXPECT_FALSE(state.CheckPublicKeyPins(domain, |
718 sni_enabled, | |
719 is_issued_by_known_root, | 713 is_issued_by_known_root, |
720 saved_hashes, | 714 saved_hashes, |
721 &failure_log)); | 715 &failure_log)); |
722 } | 716 } |
723 | 717 |
724 }; // namespace net | 718 }; // namespace net |
OLD | NEW |