Skip to content

Commit 6aaa1f6

Browse files
committed
always regenerate new cert at startup
1 parent 149d4be commit 6aaa1f6

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

src/index.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
Route,
99
} from './services/IpRegistrar.js';
1010
import {
11-
loadCertificateState,
1211
ensureKeyPair,
1312
requestCertificate,
1413
needsRenewal,
@@ -81,18 +80,12 @@ async function main() {
8180
const publicIp = config.PUBLIC_IP || (await detectPublicIp());
8281
console.log(`\nDetected public IP: ${publicIp}`);
8382

84-
// Certificate management
83+
// Certificate management - always request fresh cert at startup
84+
// This ensures we get the latest CA and certificate extensions (e.g., nip.io SAN)
8585
console.log('\nInitializing certificate...');
86-
certState = loadCertificateState();
87-
88-
if (!certState || needsRenewal(certState.expiresAt)) {
89-
const reason = !certState ? 'no certificate found' : `renewal needed (expires in ${formatTimeRemaining(certState.expiresAt)})`;
90-
console.log(`[Cert] Requesting new certificate: ${reason}`);
91-
const keyPem = await ensureKeyPair();
92-
certState = await requestCertificate(provider, keyPem, publicIp);
93-
} else {
94-
console.log(`[Cert] Certificate valid, expires in ${formatTimeRemaining(certState.expiresAt)}`);
95-
}
86+
console.log('[Cert] Requesting new certificate at startup...');
87+
const keyPem = await ensureKeyPair();
88+
certState = await requestCertificate(provider, keyPem, publicIp);
9689

9790
// Build route
9891
route = buildRoute(

0 commit comments

Comments
 (0)