You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
x509-cert: support for computing certificate fingerprints #1662
Thanks. I'll see if I can hack something together that computes the hash of a certificate. An easy to use function directly in the Certificates structures, would be preferred in the future.
Maybe it's a stretch, but I wonder if defining a trait that could be used for calculating cert fingerprints as well as key identifiers from SubjectPublicKeyInfo would be the thing to do. May also be useful for SignedAttributes in cms.
Validating of a binary was signed by a "trusted signer", e.g. a known certificate. It's very commen in the security field to do that. I've written a crate to check the authenticode signature of a PE file and then check if the signing certificate (identified by the hash) is known to be benign. https://crates.io/crates/cross-authenticode
For what it's worth, I have a fairly complete implementation of authenticode in https://github.com/nix-community/goblin-signing
This is based on goblin, and up to date with latest spec (which adds padding to make sure you do not have a change of the hash once you append the signature).
I don't know how standard it would be to hash the certificate itself or how common that is. In my experience either the name or the spki gets hash (for different reasons (threat model!)). This is the first time I've seen someone hash the full certificate as it would usually be in a trust-anchor repository.
All that to say, do you have any reference to as spec doing that?
All that to say, do you have any reference to as spec doing that?
It's sometimes referred to as certHash and is computed as SHA-1 of the entire DER serialization of the certificate, e.g. in RFC4210 (CMP): https://datatracker.ietf.org/doc/html/rfc4210
Sure, that's one usage, but certHash / "thumbprints" can be found elsewhere, e.g. the OpenSSL command line tooling, the Windows certificate manager UI, OCSP
Activity
tarcieri commentedon Feb 23, 2025
We don't have anything built-in for this AFAICT, however you can look at how the
spkicrate computes a similar fingerprint and apply it to the whole certificate: https://github.com/RustCrypto/formats/blob/a0b4200/spki/src/fingerprint.rs#L17-L42We should probably add such a feature so I will rename the issue title to reflect the potential new feature.
[-]Q: How to get a fingerprint from a certificate[/-][+]x509-cert: support for computing certificate fingerprints[/+]secana commentedon Feb 24, 2025
Thanks. I'll see if I can hack something together that computes the hash of a certificate. An easy to use function directly in the Certificates structures, would be preferred in the future.
carl-wallace commentedon Feb 24, 2025
Maybe it's a stretch, but I wonder if defining a trait that could be used for calculating cert fingerprints as well as key identifiers from SubjectPublicKeyInfo would be the thing to do. May also be useful for SignedAttributes in cms.
tarcieri commentedon Feb 24, 2025
The logic for calculating fingerprints from
spkicould be extracted and generalized intoderbaloo commentedon Apr 16, 2025
What's the use for the fingerprint?
Would this be for building a trust-ca folder? (ala
openssl rehash)I believe the hash for that is the hash of the subject, not the full certificate itself. As for the SKI, it's fairly tied to
spkisecana commentedon Apr 16, 2025
Validating of a binary was signed by a "trusted signer", e.g. a known certificate. It's very commen in the security field to do that. I've written a crate to check the authenticode signature of a PE file and then check if the signing certificate (identified by the hash) is known to be benign. https://crates.io/crates/cross-authenticode
baloo commentedon Apr 17, 2025
For what it's worth, I have a fairly complete implementation of authenticode in https://github.com/nix-community/goblin-signing
This is based on goblin, and up to date with latest spec (which adds padding to make sure you do not have a change of the hash once you append the signature).
I don't know how standard it would be to hash the certificate itself or how common that is. In my experience either the name or the spki gets hash (for different reasons (threat model!)). This is the first time I've seen someone hash the full certificate as it would usually be in a trust-anchor repository.
All that to say, do you have any reference to as spec doing that?
tarcieri commentedon Apr 17, 2025
It's sometimes referred to as
certHashand is computed as SHA-1 of the entire DER serialization of the certificate, e.g. in RFC4210 (CMP): https://datatracker.ietf.org/doc/html/rfc4210Or RFC4387: https://datatracker.ietf.org/doc/html/rfc4387#section-2.2
RFC9480 updates CMP to support alternative hash algorithms to SHA-1: https://datatracker.ietf.org/doc/rfc9480/
baloo commentedon Apr 18, 2025
That would then be in cmpv2 and would look something like #1766 ?
tarcieri commentedon Apr 18, 2025
Sure, that's one usage, but
certHash/ "thumbprints" can be found elsewhere, e.g. the OpenSSL command line tooling, the Windows certificate manager UI, OCSPbaloo commentedon Apr 18, 2025
eaa26bd then
tarcieri commentedon Apr 18, 2025
Sure
tarcieri commentedon Apr 21, 2025
@baloo I still think we should add a general method for calculating
certHashinx509-certitselfbaloo commentedon Apr 21, 2025
Something else than
formats/x509-cert/src/certificate.rs
Lines 432 to 447 in 53d2e3b
tarcieri commentedon Apr 21, 2025
Oh sorry, that’s fine