diff --git a/src/components/certificates-list/CertificatesList.tsx b/src/components/certificates-list/CertificatesList.tsx
index af938ab1..af71b09b 100644
--- a/src/components/certificates-list/CertificatesList.tsx
+++ b/src/components/certificates-list/CertificatesList.tsx
@@ -22,7 +22,10 @@ import { CertificateName } from "../certificate-name";
import { CertificateSerialNumber } from "../certificate-serial-number";
import { downloadCertificate } from "../../utils/download-certificate";
import { CopyIconButton } from "../copy-icon-button";
-import { certificateRawToPem } from "../../utils/certificate";
+import {
+ certificateRawToPem,
+ getCertificateName,
+} from "../../utils/certificate";
import { SortButton } from "../sort-button";
import { CertificateProps } from "../../types";
@@ -184,9 +187,11 @@ export const CertificatesList: React.FunctionComponent<
- {/* // TODO: not sure about label as name */}
-
+
diff --git a/src/types.ts b/src/types.ts
index ef3893b2..5babd857 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -15,6 +15,8 @@ export interface CertificateSubjectProps {
L?: string;
ST?: string;
C?: string;
+ G?: string;
+ SN?: string;
}
export type CertificateAlgorithmProps = {
diff --git a/src/utils/certificate.ts b/src/utils/certificate.ts
index 70e81f94..dcb3f4d9 100644
--- a/src/utils/certificate.ts
+++ b/src/utils/certificate.ts
@@ -1,6 +1,10 @@
import { Pkcs10CertificateRequest, X509Certificate } from "@peculiar/x509";
-import { CertificateSubjectProps, CertificateType } from "../types";
+import {
+ CertificateProps,
+ CertificateSubjectProps,
+ CertificateType,
+} from "../types";
export function certificateRawToPem(raw: ArrayBuffer, type: CertificateType) {
let pem;
@@ -33,3 +37,25 @@ export function certificateSubjectToString(
return parts.join(", ");
}
+
+export function getCertificateName(certificate: CertificateProps) {
+ const { G, CN, SN, E } =
+ certificate.subject as unknown as CertificateSubjectProps;
+
+ // Return Common Name if present.
+ if (CN) {
+ return CN;
+ }
+
+ // Return Given Name + Surname if both present.
+ if (G && SN) {
+ return `${G} ${SN}`;
+ }
+
+ // Return Email if none of the above present
+ if (E) {
+ return E;
+ }
+
+ return certificate.subjectName;
+}