chore: use import for node-forge instead of require

Signed-off-by: Johannes Grumboeck <johannes@grumboeck.net>
This commit is contained in:
Johannes Grumboeck
2022-10-23 21:49:51 +02:00
parent 35f292c9f7
commit a17a7a6cc1
3 changed files with 14 additions and 3 deletions
+1
View File
@@ -49,6 +49,7 @@
"@types/dockerode": "^3.3.0",
"@types/express": "^4.17.6",
"@types/luxon": "^3.0.0",
"@types/node-forge": "^1.3.0",
"@types/webpack-env": "^1.15.2",
"archiver": "^5.0.2",
"aws-sdk": "^2.840.0",
@@ -21,6 +21,7 @@ import * as http from 'http';
import * as https from 'https';
import { Logger } from 'winston';
import { HttpsSettings } from './config';
import * as forge from 'node-forge';
const FIVE_DAYS_IN_MS = 5 * 24 * 60 * 60 * 1000;
@@ -99,9 +100,8 @@ async function getGeneratedCertificate(hostname: string, logger?: Logger) {
if (await fs.pathExists(certPath)) {
cert = await fs.readFile(certPath);
try {
const forge = require('node-forge');
const crt = forge.pki.certificateFromPem(cert);
const crtTimestamp = Date.parse(crt.validity.notAfter);
const crt = forge.pki.certificateFromPem(cert.toString());
const crtTimestamp = Date.parse(crt.validity.notAfter.toString());
remainingMs = crtTimestamp - Date.now();
} catch (error) {
logger?.warn(`Unable to parse self-signed certificate. ${error}`);