From 586dfd36a93150a65ace3b8596c11ecad3196ece Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Mon, 18 May 2026 16:12:02 +1000 Subject: [PATCH] Fix openssl3 formatting of subject cn --- backend/internal/certificate.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/backend/internal/certificate.js b/backend/internal/certificate.js index a93bf8575..82a47b926 100644 --- a/backend/internal/certificate.js +++ b/backend/internal/certificate.js @@ -683,21 +683,15 @@ const internalCertificate = { try { const result = await utils.execFile("openssl", ["x509", "-in", certificateFile, "-subject", "-noout"]); + console.log("openssl result: ", result); // Examples: // subject=CN = *.jc21.com // subject=CN = something.example.com - // CN=something.example.com - const regex = /(?:subject=)?[^=]+=\s+(\S+)/gim; + // subject=CN=*.jc21.com + const regex = /(?:subject=)?[^=]+=\s*(\S+)/gim; const match = regex.exec(result); if (match && typeof match[1] !== "undefined") { - certData.cn = match[1]; - } else { - // CN is likely formatted differently - const regex11 = /CN=(\S+)/gim; - const match11 = regex11.exec(result); - if (match11 && typeof match11[1] !== "undefined") { - certData.cn = match11[1]; - } + certData.cn = match[1].trim(); } const result2 = await utils.execFile("openssl", ["x509", "-in", certificateFile, "-issuer", "-noout"]);