Skip to content

Commit 4ca3d0e

Browse files
authored
fix: should reuse unexpired cert (#4)
1 parent d6ada17 commit 4ca3d0e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/util.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ export const resolveHttpsConfig = (
1818
}
1919

2020
const certPath = path.join(__dirname, 'fake-cert.pem');
21+
2122
if (fs.existsSync(certPath)) {
2223
const stats = fs.statSync(certPath);
24+
const timeDiff = Date.now() - stats.mtimeMs;
25+
const daysDiff = timeDiff / (1000 * 60 * 60 * 24);
26+
2327
// Default validity period is 30 days
24-
if (stats.mtimeMs <= Date.now() - 1000 * 60 * 60 * 24 * 30) {
28+
if (daysDiff < 30) {
2529
const content = fs.readFileSync(certPath, { encoding: 'utf-8' });
2630
return {
2731
key: content,

0 commit comments

Comments
 (0)