feat(Cert Key Parser): fingerprint in hex format (#25)

* feat(Cert Key Parser): fingerprint in hex format

Add hexadecimal certificate fingerprint output and sha1 algorithm.

- Extend the certificate parser to output certificate fingerprints in both base64 and hexadecimal formats
- Include sha1 in the list of supported fingerprint algorithms to accommodate additional use cases.

* fix: typechecking

---------

Co-authored-by: sharevb <sharevb@gmail.com>
This commit is contained in:
Timothy Stottandsharevb authored and GitHub committed 2025-02-23 10:33:54 +01:00
1 parent 0a0ebddb5d
commit c57fd88886
1 file changed
+16 -10
@@ -1,4 +1,5 @@
import type {
AlgorithmHashType,
Certificate,
Fingerprint,
Key,
@@ -170,16 +171,21 @@ export function getCertificateLabelValues(cert: Certificate) {
})), null, 2),
multiline: true,
},
{
label: 'Fingerprint (sha256):',
value: onErrorReturnErrorMessage(() => cert.fingerprint('sha256')),
multiline: true,
},
{
label: 'Fingerprint (sha512):',
value: onErrorReturnErrorMessage(() => cert.fingerprint('sha512')),
multiline: true,
},
...['sha1', 'sha256', 'sha512'].flatMap(algorithm =>
[
{
label: `Fingerprint (${algorithm}):`,
value: onErrorReturnErrorMessage(() => cert.fingerprint(algorithm as AlgorithmHashType)),
multiline: true,
},
{
label: `Fingerprint HEX (${algorithm}):`,
value: onErrorReturnErrorMessage(() => cert.fingerprint(algorithm as AlgorithmHashType).toString('hex')),
multiline: true,
},
],
),
{
label: 'Certificate (pem):',
value: onErrorReturnErrorMessage(() => cert.toString('pem')),