8

I have some SW that extracts certificates data and the SW utilizes OpenSSL. I am confused what is the difference between the subjectKeyIdentifier and the sha1Fingerprint. Both are hash values. My intuition is that the subjectKeyIdentifier is the hash of the public-key of the certificate and the sha1Fingerprint is the hash of the overall fields of the certificate. My research made more confused. For example, this reference says about the subjectKeyIdentifier:

This is a hash value of the SSL certificate.

This is an example of what I get from the SW:

"subjectKeyIdentifier": "A8:4A:6A:63:04:7D:DD:BA:E6:D1:39:B7:A6:45:65:EF:F3:A8:EC:A1", "sha1Fingerprint": "E6:A3:B4:5B:06:2D:50:9B:33:82:28:2D:19:6E:FE:97:D5:95:6C:CB"

What is the difference between the two hashes? What each hash is for?

9

The subject key identifier (SKID) is an x509 extension and thus actually part of the certificate. The fingerprint instead is not part of the certificate but instead computed from the certificate. A certificate does not need to have an SKID at all and can have at most one SKID. But since the fingerprint is just a computed from the certificate there can be multiple fingerprints, like one using SHA-1, one using SHA-256, one using MD5 ...

The SKID is used to create the trust chain not based on the certificate subject and issuer but on the certificate SKID and authority key identifier (AKID). This makes it easier to deal with situations where the same subject string is used with multiple CA certificates. While the RFC 3280 describes common ways to generate SKID the only real requirement is that the SKID of the CA certificate must match the AKID in all certificates issued by this CA.

In the example below it can be clearly seen that the SKID BB:AF:7E:02:3D:FA:... of the issuer matches the AKID of the issued certificate:

    ...
    Issuer: C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Certification Authority
    ...
    Subject: C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Domain Validation Secure Server CA
    ...
    X509v3 extensions:
        X509v3 Authority Key Identifier: 
            keyid:BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4

    ----

    ...
    Issuer: C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Certification Authority
    ...
    Subject: C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Certification Authority
    ...
    X509v3 extensions:
        X509v3 Subject Key Identifier: 
            BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4
  • 2
    It might be worth mentioning that the SKI is calculated from the Subject and Public Key while the fingerprint is generated from the whole certificate. If a certificate is renewed, its SKI will stay the same, while its fingerprint will change. – garethTheRed Dec 24 '18 at 8:06
  • @garethTheRed SKI remains the same only when key pair is reused during renewal. If new key pair is generated, it will produce new SKI value. – Crypt32 Dec 24 '18 at 9:42
  • 1
    @garethTheRed: the SKI might be derived from subject and pubkey in specific (and likely many) implementations but it is not required to be done this way. From RFC 3280 section 4.2.1.2: "For CA certificates, subject key identifiers SHOULD be derived from the public key or a method that generates unique values.". But of course SKI cannot be derived from the whole certificate since the SKI itself is part of the certificate. – Steffen Ullrich Dec 24 '18 at 10:13
  • @Crypt32 - that will be a re-key, not a renewal; by RFC 3647 definition. Although renewal is often used to describe both in practice. – garethTheRed Dec 24 '18 at 10:30
  • 2
    @user9371654: the SKI is somehow related to the public key and can also be related to others (subject makes sense). It does not have to be a hash of these - it can also be some random as long as the same number is used for all certificates issued by this specific CA (and also renews of the CA using the same subject and key) and other CA certificates use different numbers. Of course, just using a hash of public key and subject would be a simple implementation which provides these properties. But it is not a requirement to implement it like this. – Steffen Ullrich Dec 24 '18 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.