From 9cfa6ea58b80f9be9a77a3ec74c48bb0e79cbac5 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 2 Apr 2026 12:45:17 -0700 Subject: [PATCH] fix: refactor serviceKey undefined handling Check serviceKey directly after parsing instead of checking existing?.serviceKey. This fixes a bug where key parsing failures would be silently ignored. --- server/src/cert.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/cert.ts b/server/src/cert.ts index 4ddbfca7d..43a6adcb3 100644 --- a/server/src/cert.ts +++ b/server/src/cert.ts @@ -15,7 +15,7 @@ export interface SelfSignedCertificate { }; export function createSelfSignedCertificate(existing?: SelfSignedCertificate): SelfSignedCertificate { - let serviceKey: ReturnType; + let serviceKey: ReturnType | undefined; // check if existing key is usable if (existing?.certificate && existing?.serviceKey && existing?.version === CURRENT_SELF_SIGNED_CERTIFICATE_VERSION) { try { @@ -30,7 +30,7 @@ export function createSelfSignedCertificate(existing?: SelfSignedCertificate): S const certificate = pki.createCertificate(); - if (existing?.serviceKey) { + if (serviceKey) { certificate.publicKey = pki.rsa.setPublicKey(serviceKey.n, serviceKey.e); } else {