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

Improvements and fixes in the X509CA disk #233

Merged
merged 5 commits into from
Jun 21, 2023

Conversation

maxlambrecht
Copy link
Contributor

@maxlambrecht maxlambrecht commented Jun 20, 2023

Pull request check list

  • Proper tests/regressions included?
  • Documentation updated?

Affected functionality

Description of change

In this PR, several improvements have been made to the X509CA disk implementation:

  • Simplify the code and rename the property in the struct from trustBundle to upstreamChain which conveys more clearly that it contains intermediates CAs to chain to an upstream trust bundle.

  • The certificate file can have either a single self-signed (root) certificate or one or more intermediate CAs that chain back to a root CA in the bundle file.

  • The bundle file should contain one or more trusted root CAs to verify to the certificates in the certificate file.

  • The certificate chain verification process has been refined to properly utilize both roots and intermediates.

  • The certificate chain verification process has been refactored into a utility function for re-usability.

  • Add a logging line when a new X.509 certificate was issued.

  • Lastly, unit tests have been added for the new utility functions.

Which issue this pull requests fixes

@maxlambrecht maxlambrecht marked this pull request as draft June 21, 2023 13:12
@maxlambrecht maxlambrecht marked this pull request as ready for review June 21, 2023 14:14
@maxlambrecht maxlambrecht changed the title Minor improvements in the X509CA disk Improvements and fixes in the X509CA disk Jun 21, 2023
@maxlambrecht maxlambrecht marked this pull request as draft June 21, 2023 16:51
@maxlambrecht maxlambrecht marked this pull request as ready for review June 21, 2023 17:48
Copy link
Collaborator

@Victorblsilveira Victorblsilveira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one suggestion, not really critical is just a clarity improvement.

Comment on lines 178 to 179
intermediates := certChain[1:]
if err := cryptoutil.VerifyCertificateChain([]*x509.Certificate{certChain[0]}, intermediates, bundle, ca.clock.Now()); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for clarity:

Suggested change
intermediates := certChain[1:]
if err := cryptoutil.VerifyCertificateChain([]*x509.Certificate{certChain[0]}, intermediates, bundle, ca.clock.Now()); err != nil {
intermediates := certChain[1:]
root := certChain[0]
if err := cryptoutil.VerifyCertificateChain([]*x509.Certificate{root}, intermediates, bundle, ca.clock.Now()); err != nil {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not correct, certChain[0] is not a root. I defined a variable with the name leafCert instead.

Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
…kage

Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
@sonarcloud
Copy link

sonarcloud bot commented Jun 21, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@maxlambrecht maxlambrecht merged commit d55c1b6 into HewlettPackard:main Jun 21, 2023
@maxlambrecht maxlambrecht deleted the x509ca-disk branch June 21, 2023 19:10
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.

2 participants