BRNameMatchingPolicy.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifndef BRNameMatchingPolicy_h
  6. #define BRNameMatchingPolicy_h
  7. #include "pkix/pkixtypes.h"
  8. namespace mozilla { namespace psm {
  9. // According to the Baseline Requirements version 1.3.3 section 7.1.4.2.2.a,
  10. // the requirements of the subject common name field are as follows:
  11. // "If present, this field MUST contain a single IP address or Fully‐Qualified
  12. // Domain Name that is one of the values contained in the Certificate’s
  13. // subjectAltName extension". Consequently, since any name information present
  14. // in the common name must be present in the subject alternative name extension,
  15. // when performing name matching, it should not be necessary to fall back to the
  16. // common name. Because this consequence has not commonly been enforced, this
  17. // implementation provides a mechanism to start enforcing it gradually while
  18. // maintaining some backwards compatibility. If configured with the mode
  19. // "EnforceAfter23August2016", name matching will only fall back to using the
  20. // subject common name for certificates where the notBefore field is before 23
  21. // August 2016. Similarly, the mode "EnforceAfter23August2015" is also
  22. // available. This is to provide a balance between allowing preexisting
  23. // long-lived certificates and detecting newly-issued problematic certificates.
  24. // Note that this implementation does not actually directly enforce that if the
  25. // subject common name is present, its value corresponds to a dNSName or
  26. // iPAddress entry in the subject alternative name extension.
  27. class BRNameMatchingPolicy : public mozilla::pkix::NameMatchingPolicy
  28. {
  29. public:
  30. enum class Mode {
  31. DoNotEnforce = 0,
  32. EnforceAfter23August2016 = 1,
  33. EnforceAfter23August2015 = 2,
  34. Enforce = 3,
  35. };
  36. explicit BRNameMatchingPolicy(Mode mode)
  37. : mMode(mode)
  38. {
  39. }
  40. virtual mozilla::pkix::Result FallBackToCommonName(
  41. mozilla::pkix::Time notBefore,
  42. /*out*/ mozilla::pkix::FallBackToSearchWithinSubject& fallBacktoCommonName)
  43. override;
  44. private:
  45. Mode mMode;
  46. };
  47. } } // namespace mozilla::psm
  48. #endif // BRNameMatchingPolicy_h