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

[v4.y] Load cluster ca certificates using OpenSSL::X509::Store#add_file #552

Merged
merged 5 commits into from
Mar 23, 2022

Conversation

cben
Copy link
Collaborator

@cben cben commented Mar 22, 2022

Backporting #461 (which fixed #460) + tests.

@cben cben force-pushed the v4.y-openssl-x509-store-add-file branch 2 times, most recently from 03a206e to 2c4f23b Compare March 22, 2022 21:52
@cben
Copy link
Collaborator Author

cben commented Mar 22, 2022

@jperville @DocX I'm backporting the add_file fix here which will allow me to finally release it (sorry for huge delay).

Added tests and CI keeps failing on Mac — any idea if add_file might behave differently by OS?

EDIT: note my test was not for root+intermediate scenario; it's a simple sandwitch of 3 unrelated CA certs, of which only the middle one should match.

elsif cluster.key?('certificate-authority-data')
Base64.decode64(cluster['certificate-authority-data'])
ca_cert_data = Base64.decode64(cluster['certificate-authority-data'])
cert_store.add_cert(OpenSSL::X509::Certificate.new(ca_cert_data))
Copy link
Collaborator Author

@cben cben Mar 22, 2022

Choose a reason for hiding this comment

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

Umm, looks like the fix only covered certificate-authority, but certificate-authority-data would still have the bug.

  • need to add test with concatenated inline data.
  • can we fix it?
  • if not, correct CHANGELOG to explain partial fix.

Test sandwitches the real CA cert between two unrelated CA certs
(another-ca1.pem, another-ca2.pem, simply copied from two runs of
update_certs_k0s.rb).
No test for root+intermediate scenario.

Fails before the backport of ManageIQ#461:

KubeclientConfigTest#test_concatenated_ca [/home/beni/kubeclient/test/test_config.rb:196]:
Expected false to be truthy.

(some experimenting with order suggests only first cert is honored.)
Passes with the fix.
…-add-file

Load cluster ca certificates using OpenSSL::X509::Store#add_file

(cherry picked from commit 53408c1)
@cben cben force-pushed the v4.y-openssl-x509-store-add-file branch 2 times, most recently from 3f43a3e to 1521fcd Compare March 23, 2022 07:47
@cben
Copy link
Collaborator Author

cben commented Mar 23, 2022

Oops, maybe the Mac angle was my mistake.

The cert I put in middle of concatenated-ca.pem didn't match the existing certs, so it failed rake test. OTOH linux doesn't run rake test on existing certs, it only runs tests inside
test/config/update_certs_k0s.rb which regenerates all certs consistently, therefore it passed.

I'm changing CI to complete all tests when one errors to get clearer picture => 🎉 mac passed.
(windows — which I never tried in CI before — failed to install gems, I'll track that in separate PR => #553)

Still not handling certificate-authority-data. OK, I'll document and release soon the partial fix — better than nothing.

- Helps confirm suspected OS-specific failures.
- Normally when one build fails, most other builds already started and
  some almost complete `bundle install` / started tests.
  So it's not a big "waste" expensive to let them finish, arguably it's
  actually a waste to abort them! (sunken cost fallacy? :-)
- In case rubocop complains, while I do consider it a merge blocker,
  it's better contributor (and maintainer) experience to also see test results.
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.

None yet

1 participant