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

Sort the DNS Names in the SANs #4624

Merged

Conversation

Mehdi-Bendriss
Copy link
Contributor

@Mehdi-Bendriss Mehdi-Bendriss commented Aug 6, 2024

Description

  • Category: Bug fix
  • Why these changes are required?
    • During the hot reload of a certificate, comparing equivalent certificates with multiple DNS Names on the SAN will fail if the order of the entries doesn't match.
  • What is the old behavior before changes and new behavior after changes?
    • Previously, the DN list of the old vs new certificates was compared as it was read, while this PR ensures both lists are sorted prior to the comparison

Issues Resolved

#4480

Testing

manual testing - as it is a pretty straightforward change.
happy to add a unit test if needed

Check List

  • New functionality includes testing
  • New functionality has been documented
  • New Roles/Permissions have a corresponding security dashboards plugin PR
  • API changes companion pull request created
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@willyborankin
Copy link
Collaborator

@Mehdi-Bendriss, thank you for your contribution. Unfortunately, it won't fix the problem. The method where you added the comparison is used only in the REST API. To address the bug, you need to sort the DN names in the method at:

private boolean hasValidDNs(final X509Certificate[] currentX509Certs, final X509Certificate[] newX509Certs) {
method.

@Mehdi-Bendriss
Copy link
Contributor Author

Mehdi-Bendriss commented Aug 6, 2024

@willyborankin thanks for the response.

I am not sure I'm following. The sorting in my PR happens in getSubjectAlternativeNames which is then called from within hasValidDNs (the method you linked) for both old and new certificates.

Is my understanding correct or did I miss something?

@willyborankin
Copy link
Collaborator

@willyborankin thanks for the response.

I am not sure I'm following. The sorting in my PR happens in getSubjectAlternativeNames which is then called from within hasValidDNs for both the old and new certificates.

Is my understanding correct or did I miss something?

Ahh sorry didn't notice Function<> in the method. All good my comment is misleading.

Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.27%. Comparing base (ef19743) to head (e188dfc).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4624      +/-   ##
==========================================
+ Coverage   65.24%   65.27%   +0.03%     
==========================================
  Files         317      317              
  Lines       22309    22311       +2     
  Branches     3588     3588              
==========================================
+ Hits        14555    14563       +8     
+ Misses       5960     5954       -6     
  Partials     1794     1794              
Files Coverage Δ
...ensearch/security/ssl/DefaultSecurityKeyStore.java 66.66% <100.00%> (+0.12%) ⬆️

... and 3 files with indirect coverage changes

@willyborankin
Copy link
Collaborator

LGTM. One last thing you need to sign off your commits using git:
git commit --signoff

Signed-off-by: Mehdi Bendriss <mehdi.bendriss@canonical.com>
Signed-off-by: Mehdi Bendriss <mehdi.bendriss@canonical.com>
Signed-off-by: Mehdi Bendriss <mehdi.bendriss@canonical.com>
Signed-off-by: Mehdi Bendriss <mehdi.bendriss@canonical.com>
Signed-off-by: Mehdi Bendriss <mehdi.bendriss@canonical.com>
@Mehdi-Bendriss
Copy link
Contributor Author

Mehdi-Bendriss commented Aug 12, 2024

@willyborankin I signed off all commits, the DCO step still fails. Any idea?

@cwperks
Copy link
Member

cwperks commented Aug 13, 2024

@willyborankin I signed off all commits, the DCO step still fails. Any idea?

I manually set it to pass. All of the commits are signed.

@willyborankin willyborankin added the backport 2.x backport to 2.x branch label Aug 13, 2024
@willyborankin willyborankin merged commit a6fb2d4 into opensearch-project:main Aug 13, 2024
43 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 13, 2024
(cherry picked from commit a6fb2d4)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants