-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add support for FQDN K8s API servers and Root CA chains #144
Conversation
* Add [CAStore](https://github.com/elixir-mint/castore) dependency for root CAs * This adds support for k8s servers using TLS certs with a custody chain back to a root certificate authority. i.e. no intermediate certificates * This would be typical of any k8s server with a public API available at a FQDN with a TLS cert whose chain of custody is covered by the root certificate authorities. * Sets the default ca_provider on K8s.Conn to CAStore * Sets the default cacertfile parameter for ssl_options to `conn.ca_provider` * Update `conn_test.exs` assertions for ssl_options * This makes the default when not using an intermediate certificate chain to use the root CA certificate chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks @thephw!
mix.exs
Outdated
@@ -35,6 +35,7 @@ defmodule K8s.MixProject do | |||
# Run "mix help deps" to learn about dependencies. | |||
defp deps do | |||
[ | |||
{:castore, ">= 0.0.0"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not {:castore, "~> 0.1.0"}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right it'd probably be better to pin to the minor version. At the moment they are functionally equivalent all releases are 0.1.X
, but we could protect against any major API changes by pinning it to the minor version. Let me update that real quick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 👍🏻
- Ref: coryodaniel#144 - I missed a codepath in the original PR that makes this not work with a call from K8s.Conn.from_file when using a FQDN for the server url.
Problem
Our k8s API servers use a fully qualified domain name and TLS certs from LetsEncrypt. In the current implementation no root CA certfiles are provided to HTTPoison. This causes an error when trying to configure and use a connection like below with
:verify_peer
. This is a bit unexpected.Prior Art
Looked at a handful of other elixir libraries to see how they were managing root CA files. Most of them were using CAStore
Solution
Add CAStore dependency and integrate
cacertfile
option into K8s.Conn withCAStore.file_path()
as the default.Changelog
conn. cacertfile
conn_test.exs
assertions for ssl_options