From a48b15ea8444edb0d138d2f6466b5dd7555909e3 Mon Sep 17 00:00:00 2001 From: alex-slobodian Date: Fri, 11 Oct 2024 11:46:46 +0300 Subject: [PATCH] Fix certificate name --- src/utils/certificate.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/utils/certificate.ts b/src/utils/certificate.ts index 622e98e..b88e009 100644 --- a/src/utils/certificate.ts +++ b/src/utils/certificate.ts @@ -42,27 +42,22 @@ export function getCertificateName(certificate: CertificateProps) { if (!certificate.subject) { return certificate.subjectName; } - const subject = Object.fromEntries( - Object.entries(certificate.subject).map(([key, value]) => [ - key, - Array.isArray(value) ? value[0] : value, // Take the first element if value is an array - ]) - ); - const { G, CN, SN, E } = subject; + + const { G, CN, SN, E } = certificate.subject; // Return Common Name if present. if (CN) { - return CN; + return CN[0]; } // Return Given Name + Surname if both present. if (G && SN) { - return `${G} ${SN}`; + return `${G[0]} ${SN[0]}`; } // Return Email if none of the above present if (E) { - return E; + return E[0]; } return certificate.subjectName;