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

certificate serialNumber is not match #12

Open
Randyshu2018 opened this issue Jun 16, 2020 · 0 comments
Open

certificate serialNumber is not match #12

Randyshu2018 opened this issue Jun 16, 2020 · 0 comments

Comments

@Randyshu2018
Copy link

Randyshu2018 commented Jun 16, 2020

node version:10.15.3

steps to reproduce:

  1. test certificate named cert.pem:
-----BEGIN CERTIFICATE-----
MIICKjCCAdGgAwIBAgIRAMGjl2AnD3bzdpQOcPOZ944wCgYIKoZIzj0EAwIwczEL
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
cmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh
Lm9yZzEuZXhhbXBsZS5jb20wHhcNMjAwNjEyMDY0ODAwWhcNMzAwNjEwMDY0ODAw
WjBsMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN
U2FuIEZyYW5jaXNjbzEPMA0GA1UECxMGY2xpZW50MR8wHQYDVQQDDBZVc2VyMUBv
cmcxLmV4YW1wbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAExkNePVH3
8oQj1J2uBWU8e1E6GuvxKy3+yutI0+d2UVrMYkfu23Z+hvKiqmXI+DX1VUTmuaF9
2du+kflKIS+Z0qNNMEswDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYD
VR0jBCQwIoAgMofBUJnNe9UyITG0/au3jfNeJ4+g377clNphXQOvfIwwCgYIKoZI
zj0EAwIDRwAwRAIgfzDtKejEx21PP/Vx2NPmaAVnAqPY30xMKAKCNVvYaSoCIAvT
1rwBNvde855LUwMGtx3mBXx13gGrCl5dXxCXZHxG
-----END CERTIFICATE-----
  1. test.js
const cp = require('child_process');
const fs = require('fs');
const { Certificate } = require('@fidm/x509');

const filePath = 'cert.pem';

const cert = Certificate.fromPEM(fs.readFileSync(filePath));
console.log(`serial=${cert.serialNumber}`);

cp.spawn('openssl', [
    'x509',
    '-in',
    `${filePath}`,
    '-serial',
    "-noout"
], { stdio: "inherit" });
  1. run
node test.js
  1. output
serial=00c1a39760270f76f376940e70f399f78e
serial=C1A39760270F76F376940E70F399F78E
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