Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snippet: Get fingerprint and serialnumber from certificate key #11

Open
trasherdk opened this issue Jan 14, 2023 · 0 comments
Open

Snippet: Get fingerprint and serialnumber from certificate key #11

trasherdk opened this issue Jan 14, 2023 · 0 comments

Comments

@trasherdk
Copy link
Owner

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)

@trasherdk trasherdk changed the title Snoppet: Get fingerprint and serialnumber from certificate key Snippet: Get fingerprint and serialnumber from certificate key May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant