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