Skip to content

Snippet: Get fingerprint and serialnumber from certificate key #11

@trasherdk

Description

@trasherdk
const crypto = require('crypto');

const getCertIdentifier = (cert, unique = true) => {
  try {
    const x509 = new crypto.X509Certificate(Buffer.from(cert));
    return unique ? x509.fingerprint256 : x509.serialNumber;
  } catch {
    return null;
  }
};

const identifier = getCertIdentifier('<cert in pem format>');

Source: uNetworking/uWebSockets#1548 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions