Open NuSkooler opened 8 years ago
As luck would have it, after playing with this all of today and a bit yesterday I finally figured it out (though perhaps there is a better way):
const fingerprint = forge.md.sha1.create().update(forge.asn1.toDer(forge.pki.certificateToAsn1(cert)).getBytes()).digest().toHex();
Looks like that's probably the right way to do it. I don't think we have a certificate fingerprinting helper function (we only have one for public keys), but I suspect it would do the same thing. Everyone likes to do these things a little differently as well -- so I'm not sure if we'll add it. I'll leave this open for now in case people have opinions on the matter.
@dlongley Thanks for your response. I'm not too sure either about how prevalent this method of cert fingerprinting is. FWIW, it's at least used by HAProxy and I believe openssl x509 ... -fingerprint
I've successfully generated a new certificate signed with my own CA. This cert is used as the client certificate when communicating with a HAProxy back end (SSL termination). From there, I forward the client cert SHA-1 fingerprint via a HTTP header using HA's
ssl_c_sha1
capture.What I'm having trouble with is calculating a matching fingerprint via forge at certificate generation time (that I can later use to validate with).
From HAProxy's documentation on
ssl_c_sha1
:Any ideas?
PS: Thanks for such a great node module!