summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/validateCertificatePath.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2022-01-29 13:12:04 -0800
committerMatthew Miller <matthew@millerti.me>2022-01-29 13:12:04 -0800
commit3441a2d49a67b06fec56220b47a9ed538078ce45 (patch)
treee9b2987897ca9b61fce04eba925aec7ca4e40fd4 /packages/server/src/helpers/validateCertificatePath.ts
parent2348fb1b0a28f51c4d2e86deba506aa800d0cd90 (diff)
Mock global.Date instead of refactoring
Diffstat (limited to 'packages/server/src/helpers/validateCertificatePath.ts')
-rw-r--r--packages/server/src/helpers/validateCertificatePath.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/packages/server/src/helpers/validateCertificatePath.ts b/packages/server/src/helpers/validateCertificatePath.ts
index 32c1c6b..8cacb0b 100644
--- a/packages/server/src/helpers/validateCertificatePath.ts
+++ b/packages/server/src/helpers/validateCertificatePath.ts
@@ -4,7 +4,6 @@
import { KJUR, X509, ASN1HEX, zulutodate } from 'jsrsasign';
import isCertRevoked from './isCertRevoked';
-import { validateCertificateValidityWindow } from './validateCertificateValidityWindow';
const { crypto } = KJUR;
@@ -81,7 +80,8 @@ async function _validatePath(certificates: string[]): Promise<boolean> {
const notBefore = zulutodate(issuerCert.getNotBefore());
const notAfter = zulutodate(issuerCert.getNotAfter());
- if (!validateCertificateValidityWindow(notBefore, notAfter)) {
+ const now = new Date(Date.now());
+ if (notBefore > now || notAfter < now) {
throw new Error('Intermediate certificate is not yet valid or expired');
}