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

fix(plugin): fix hashing of certificate chains with Mbed tls #6233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MikeGranby
Copy link
Contributor

Include only first certificate of a chain in SHA1 thumbprint hash.

Closes #6232

Include only first certificate of a chain in SHA1 thumbprint hash.

Closes open62541#6232
@jpfr
Copy link
Member

jpfr commented Jan 17, 2024

Thanks for this.

We recently added something very similar:

getLeafCertificate(UA_ByteString chain) {

I'd like to see the following:

  • Use the existing getLeafCertificate internally. So we only pass the leaf certificate into the plugin. There is only a small number of places where we call the thumbprint method callback. That solves the problem for OpenSSL at the same time.
  • Do the change for the 1.4 branch. From this it gets merged to master.

Keep up the good work!

@MikeGranby
Copy link
Contributor Author

MikeGranby commented Jan 17, 2024

A couple of observations:

  • The OpenSSL path uses x509_digest which I believe already handles the DER decoding to ensure it gets the right data size, although I don't have an openssl build running here so I'm not 100% sure. We could certainly handle trimming the cert list earlier in the process, but I did it in mbed since that seemed to be where the problem is; and

  • The getLeafCertificate implementation assumes a two byte length encoding of the certificate, which is probably reasonable in canonical form when considering the likely size of such an object, but in theory, the length could be an arbitrary number of bytes.

I'll rework this per your suggestions, but I will also improve getLeafCertificate to handle arbitrary lengths.

@jpfr
Copy link
Member

jpfr commented Jan 17, 2024

Sounds great!

@MikeGranby
Copy link
Contributor Author

Oh, and can you email me at mikeg@mikeg.net? Want to discuss any plans to add this library to Alpine as a package.

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

Successfully merging this pull request may close these issues.

Mbed Thumbprint Calculation Incorrect with Certificate Chains
2 participants