BRNameMatchingPolicy.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "BRNameMatchingPolicy.h"
  6. #include "mozilla/Assertions.h"
  7. using namespace mozilla::psm;
  8. using namespace mozilla::pkix;
  9. Result
  10. BRNameMatchingPolicy::FallBackToCommonName(
  11. Time notBefore,
  12. /*out*/ FallBackToSearchWithinSubject& fallBackToCommonName)
  13. {
  14. // (new Date("2015-08-23T00:00:00Z")).getTime() / 1000
  15. static const Time AUGUST_23_2015 = TimeFromEpochInSeconds(1440288000);
  16. // (new Date("2016-08-23T00:00:00Z")).getTime() / 1000
  17. static const Time AUGUST_23_2016 = TimeFromEpochInSeconds(1471910400);
  18. switch (mMode)
  19. {
  20. case Mode::Enforce:
  21. fallBackToCommonName = FallBackToSearchWithinSubject::No;
  22. break;
  23. case Mode::EnforceAfter23August2015:
  24. fallBackToCommonName = notBefore > AUGUST_23_2015
  25. ? FallBackToSearchWithinSubject::No
  26. : FallBackToSearchWithinSubject::Yes;
  27. break;
  28. case Mode::EnforceAfter23August2016:
  29. fallBackToCommonName = notBefore > AUGUST_23_2016
  30. ? FallBackToSearchWithinSubject::No
  31. : FallBackToSearchWithinSubject::Yes;
  32. break;
  33. case Mode::DoNotEnforce:
  34. fallBackToCommonName = FallBackToSearchWithinSubject::Yes;
  35. break;
  36. default:
  37. MOZ_CRASH("Unexpected Mode");
  38. }
  39. return Success;
  40. }