-
Notifications
You must be signed in to change notification settings - Fork 124
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: authn-k8s websocket client SNI #2516
Conversation
spec/app/domain/authentication/authn_k8s/web_socket_client_spec_spec.rb
Outdated
Show resolved
Hide resolved
05389c9
to
1156b6b
Compare
These commits will be merged into master from a different branch shortly. |
Refactors test cases. Remove spec_helper dependency to allow tests to run in isolation. Split out websocket test server into separate file.
Code Climate has analyzed commit fd4b452 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 88.0% (-1.5% change). View more on Code Climate. |
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.
lgtm
Context
Link to initial SNI PR
I'm working with a Rancher deployment based off https://github.com/rancher/quickstart. My understanding is that the deployment uses Traefik (with SNI) to expose a public endpoint. In this case to connect to the Rancher API (for the purposes of consuming the Kubernetes API of an underlying cluster) requires a client that supports SNI. The Kubernetes authenticator in Conjur fails to connect to this Rancher API.
I did some digging and found out what was causing the issue. It appears that SNI is only applied when the
ssl_version
parameter (ofAuthentication::AuthnK8s::WebSocketClient
) is set to something other than the default:SSLv23
. The unit tests forAuthentication::AuthnK8s::WebSocketClient
validate this behavior by setting the value of thessl_version
parameter to:TLSv1
. However, in actual usage ofAuthentication::AuthnK8s::WebSocketClient
within the Kubernetes authenticator controller thessl_version
parameter is never set, is therefore always set to the default and therefore Conjur at present has no SNI support.This begs the question "what about the E2E tests?". The E2E tests are not actually validating anything at all, since they are passing even though the implementation is borked.
I couldn't make sense of why we have the
ssl_version
parameter at all if it never explicitly set in actual usage, or why it defaults to:SSLv23
. I did some digging and landed on the understanding that we sort of just copied that from https://github.com/shokai/websocket-client-simple/blob/master/lib/websocket-client-simple/client.rb#L22-L31.To better make sense of things, I looked to Ruby's standard library's
Net::HTTP
for a canonical implementation of establishing a TLS connection that supports SNI. See the code at https://github.com/ruby/net-http/blob/master/lib/net/http.rb#L982-L1084. This guided the changes I have made.My intended changes are, though I might not get to all of them:
ssl_version
of:SSLv23
. My understanding is that leaving thessl_version
parameter without a default results in the socket assuming theOpenSSL
defaults specified at https://github.com/cyberark/conjur/blob/master/config/initializers/openssl.rb. We retain thessl_version
parameter to facilitate testing.ENV['SSL_CERT_DIRECTORY']
?ca_cert
Conjur secret field which is configuration that is local to the Kubernetes authenticator. Though in the case of the Kubernetes authenticator the ca_cert field is a required field.Desired Outcome
Please describe the desired outcome for this PR. Said another way, what was
the original request that resulted in these code changes? Feel free to copy
this information from the connected issue.
Implemented Changes
Describe how the desired outcome above has been achieved with this PR. In
particular, consider:
Connected Issue/Story
Resolves #[relevant GitHub issue(s), e.g. 76]
CyberArk internal issue link: insert issue ID
Definition of Done
At least 1 todo must be completed in the sections below for the PR to be
merged.
Changelog
CHANGELOG update
Test coverage
changes, or
Documentation
README
s) were updated in this PRBehavior
Security