Skip to content

Commit

Permalink
Force certificates with a validity period longer than 365 days to be …
Browse files Browse the repository at this point in the history
…refreshed.
  • Loading branch information
iclanton committed Mar 20, 2023
1 parent e006e8f commit 4a92185
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/debug-certificate-manager",
"comment": "Force certificates with a validity period longer than the expected validity period to be refreshed.",
"type": "patch"
}
],
"packageName": "@rushstack/debug-certificate-manager"
}
11 changes: 11 additions & 0 deletions libraries/debug-certificate-manager/src/CertificateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const FRIENDLY_NAME: string = 'debug-certificate-manager Development Certificate
const MAC_KEYCHAIN: string = '/Library/Keychains/System.keychain';
const CERTUTIL_EXE_NAME: string = 'certutil';
const CA_ALT_NAME: string = 'rushstack-certificate-manager.localhost';
const ONE_DAY_IN_MILLISECONDS: number = 24 * 60 * 60 * 1000;

/**
* The set of names the certificate should be generated for, by default.
Expand Down Expand Up @@ -152,6 +153,16 @@ export class CertificateManager {
);
}

if (
notBefore.getTime() - notAfter.getTime() >
optionsWithDefaults.validityInDays * ONE_DAY_IN_MILLISECONDS
) {
messages.push(
"The existing development certificate's validity period is longer " +
`than ${optionsWithDefaults.validityInDays} days.`
);
}

const { caCertificateData } = this._certificateStore;

if (!caCertificateData) {
Expand Down

0 comments on commit 4a92185

Please sign in to comment.