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

Errors are unnecessarily logged on client prior to certificate being injected #119

Closed
1 task done
eranha opened this issue Apr 20, 2020 · 4 comments
Closed
1 task done

Comments

@eranha
Copy link

eranha commented Apr 20, 2020

Afte the CSR is sent the server and the response is being sent out-of-band, the client yields errors to log while attempting to load the certificate, until the server injects the certificate to the client. This type of output can be alarming to see and unhelpful so it would be good to only show this when there is a real problem getting the certificate.

AC:

  • Certificate reading errors should only be logged when we are sure that the server failed to inject the signed cert
INFO: 2020/04/20 08:23:44 main.go:43: CAKC006I Authenticating as user '&{host/conjur/authn-k8s/conjur-5-e799170e-f-test/apps/test-app-5-e799170e-f/service_account/oc-test-app-summon-init host.conjur.authn-k8s.conjur-5-e799170e-f-test.apps test-app-5-e799170e-f.service_account.oc-test-app-summon-init}'
INFO: 2020/04/20 08:23:44 authenticator.go:181: CAKC005I Trying to login Conjur...
INFO: 2020/04/20 08:23:44 authenticator.go:113: CAKC007I Logging in as user &{host/conjur/authn-k8s/conjur-5-e799170e-f-test/apps/test-app-5-e799170e-f/service_account/oc-test-app-summon-init host.conjur.authn-k8s.conjur-5-e799170e-f-test.apps test-app-5-e799170e-f.service_account.oc-test-app-summon-init}.
INFO: 2020/04/20 08:23:44 requests.go:23: CAKC011I Login request to: https://conjur-follower.conjur-5-e799170e-f-test.svc.cluster.local/api/authn-k8s/conjur-5-e799170e-f-test/inject_client_cert
ERROR: 2020/04/20 08:23:44 authenticator.go:140: CAKC011E Client certificate not found at '/etc/conjur/ssl/client.pem'
ERROR: 2020/04/20 08:23:44 authenticator.go:184: CAKC015E Login failed
ERROR: 2020/04/20 08:23:44 main.go:46: CAKC016E Failed to authenticate
INFO: 2020/04/20 08:23:46 main.go:43: CAKC006I Authenticating as user '&{host/conjur/authn-k8s/conjur-5-e799170e-f-test/apps/test-app-5-e799170e-f/service_account/oc-test-app-summon-init host.conjur.authn-k8s.conjur-5-e799170e-f-test.apps test-app-5-e799170e-f.service_account.oc-test-app-summon-init}'
INFO: 2020/04/20 08:23:46 authenticator.go:181: CAKC005I Trying to login Conjur...
INFO: 2020/04/20 08:23:46 authenticator.go:113: CAKC007I Logging in as user &{host/conjur/authn-k8s/conjur-5-e799170e-f-test/apps/test-app-5-e799170e-f/service_account/oc-test-app-summon-init host.conjur.authn-k8s.conjur-5-e799170e-f-test.apps test-app-5-e799170e-f.service_account.oc-test-app-summon-init}.
INFO: 2020/04/20 08:23:46 requests.go:23: CAKC011I Login request to: https://conjur-follower.conjur-5-e799170e-f-test.svc.cluster.local/api/authn-k8s/conjur-5-e799170e-f-test/inject_client_cert
INFO: 2020/04/20 08:23:46 authenticator.go:187: CAKC002I Logged in
INFO: 2020/04/20 08:23:46 authenticator.go:170: CAKC008I Cert expires: 2020-04-23 08:23:44 +0000 UTC
INFO: 2020/04/20 08:23:46 authenticator.go:171: CAKC009I Current date: 2020-04-20 08:23:46.685910936 +0000 UTC
INFO: 2020/04/20 08:23:46 authenticator.go:172: CAKC010I Buffer time:  30s
INFO: 2020/04/20 08:23:46 requests.go:47: CAKC012I Authn request to: https://conjur-follower.conjur-5-e799170e-f-test.svc.cluster.local/api/authn-k8s/conjur-5-e799170e-f-test/my-account/host%2Fconjur%2Fauthn-k8s%2Fconjur-5-e799170e-f-test%2Fapps%2Ftest-app-5-e799170e-f%2Fservice_account%2Foc-test-app-summon-init/authenticate
INFO: 2020/04/20 08:23:46 authenticator.go:250: CAKC001I Successfully authenticated
@sgnn7
Copy link
Contributor

sgnn7 commented Apr 24, 2020

Hi @eranha,
The problem here is that to avoid using "secret zero" and prevent DoSing the server with open connections, we have to do the injection of the certificate in an out-of-band async fashion into the container.

With that pre-requisite as a starting point, we do not have too many reliable options available to us from the authenticator. Are you suggesting that we use a different type of checks? If so, there is room for improvement here for sure but as-is described, this behavior is not exactly a bug. Let us know what you wanted to specifically to see here and we can try to refine the issue.

@eranha
Copy link
Author

eranha commented Apr 25, 2020

The error is logged because the certificate has not been injected yet. You can wait/retry for it, and only log an error after timeout

@sgnn7
Copy link
Contributor

sgnn7 commented Apr 28, 2020

Hi @eranha,
I think I see what you mean. I will update the issue with clearer info then.

@sgnn7 sgnn7 changed the title Client Yields Login Failed Error prior to Certificate being Injected Don't log errors on client prior to certificate being injected Apr 28, 2020
@sgnn7 sgnn7 changed the title Don't log errors on client prior to certificate being injected Errors are unnecessarily logged on client prior to certificate being injected Apr 28, 2020
@sigalsax
Copy link
Contributor

See more detail here: #146
Solution design by @oburstein-hub here

@micahlee micahlee self-assigned this Aug 28, 2020
orenbm added a commit that referenced this issue Sep 13, 2020
### Fixed
- Logs now correctly print only the Conjur identity without the policy branch prefix.
  ([#126](#126))
- When authentication fails, the exponential backoff retry is correctly reset so
  that it will continue to attempt to authenticate until backoff is exhausted.
  ([#158](#158))

### Changed
- Wait slightly for the client certificate file to exist after login before
  raising an error.
  [#119](#119)
orenbm added a commit that referenced this issue Sep 13, 2020
### Fixed
- Logs now correctly print only the Conjur identity without the policy branch prefix.
  ([#126](#126))
- When authentication fails, the exponential backoff retry is correctly reset so
  that it will continue to attempt to authenticate until backoff is exhausted.
  ([#158](#158))

### Changed
- Wait slightly for the client certificate file to exist after login before
  raising an error.
  [#119](#119)
orenbm added a commit that referenced this issue Sep 13, 2020
### Fixed
- Logs now correctly print only the Conjur identity without the policy branch prefix.
  ([#126](#126))
- When authentication fails, the exponential backoff retry is correctly reset so
  that it will continue to attempt to authenticate until backoff is exhausted.
  ([#158](#158))

### Changed
- Wait slightly for the client certificate file to exist after login before
  raising an error.
  [#119](#119)
@eladkug eladkug closed this as completed Oct 1, 2020
orenbm added a commit to cyberark/secretless-broker that referenced this issue Oct 8, 2020
This version introduces some changes that we can benefit from, especially these:
- Errors in the certificate injection process on login are now printed to the client logs.
  [cyberark/conjur-authn-k8s-client#/170](cyberark/conjur-authn-k8s-client#170)
- When authentication fails, the exponential backoff retry is correctly reset so
  that it will continue to attempt to authenticate until backoff is exhausted.
  [cyberark/conjur-authn-k8s-client#158](cyberark/conjur-authn-k8s-client#158)
- Wait slightly for the client certificate file to exist after login before
  raising an error.
  [cyberark/conjur-authn-k8s-client#119](cyberark/conjur-authn-k8s-client#119)
orenbm added a commit to cyberark/secretless-broker that referenced this issue Oct 8, 2020
This version introduces some changes that we can benefit from, especially these:
- Errors in the certificate injection process on login are now printed to the client logs.
  [cyberark/conjur-authn-k8s-client#/170](cyberark/conjur-authn-k8s-client#170)
- When authentication fails, the exponential backoff retry is correctly reset so
  that it will continue to attempt to authenticate until backoff is exhausted.
  [cyberark/conjur-authn-k8s-client#158](cyberark/conjur-authn-k8s-client#158)
- Wait slightly for the client certificate file to exist after login before
  raising an error.
  [cyberark/conjur-authn-k8s-client#119](cyberark/conjur-authn-k8s-client#119)
orenbm added a commit to cyberark/secretless-broker that referenced this issue Oct 8, 2020
This version introduces some changes that we can benefit from, especially these:
- Errors in the certificate injection process on login are now printed to the client logs.
  [cyberark/conjur-authn-k8s-client#/170](cyberark/conjur-authn-k8s-client#170)
- When authentication fails, the exponential backoff retry is correctly reset so
  that it will continue to attempt to authenticate until backoff is exhausted.
  [cyberark/conjur-authn-k8s-client#158](cyberark/conjur-authn-k8s-client#158)
- Wait slightly for the client certificate file to exist after login before
  raising an error.
  [cyberark/conjur-authn-k8s-client#119](cyberark/conjur-authn-k8s-client#119)
orenbm added a commit to cyberark/secretless-broker that referenced this issue Oct 8, 2020
This version introduces some changes that we can benefit from, especially these:
- Errors in the certificate injection process on login are now printed to the client logs.
  [cyberark/conjur-authn-k8s-client#/170](cyberark/conjur-authn-k8s-client#170)
- When authentication fails, the exponential backoff retry is correctly reset so
  that it will continue to attempt to authenticate until backoff is exhausted.
  [cyberark/conjur-authn-k8s-client#158](cyberark/conjur-authn-k8s-client#158)
- Wait slightly for the client certificate file to exist after login before
  raising an error.
  [cyberark/conjur-authn-k8s-client#119](cyberark/conjur-authn-k8s-client#119)
orenbm added a commit to cyberark/secretless-broker that referenced this issue Oct 8, 2020
This version introduces some changes that we can benefit from, especially these:
- Errors in the certificate injection process on login are now printed to the client logs.
  [cyberark/conjur-authn-k8s-client#/170](cyberark/conjur-authn-k8s-client#170)
- When authentication fails, the exponential backoff retry is correctly reset so
  that it will continue to attempt to authenticate until backoff is exhausted.
  [cyberark/conjur-authn-k8s-client#158](cyberark/conjur-authn-k8s-client#158)
- Wait slightly for the client certificate file to exist after login before
  raising an error.
  [cyberark/conjur-authn-k8s-client#119](cyberark/conjur-authn-k8s-client#119)
orenbm added a commit to cyberark/secretless-broker that referenced this issue Oct 8, 2020
This version introduces some changes that we can benefit from, especially these:
- Errors in the certificate injection process on login are now printed to the client logs.
  [cyberark/conjur-authn-k8s-client#/170](cyberark/conjur-authn-k8s-client#170)
- When authentication fails, the exponential backoff retry is correctly reset so
  that it will continue to attempt to authenticate until backoff is exhausted.
  [cyberark/conjur-authn-k8s-client#158](cyberark/conjur-authn-k8s-client#158)
- Wait slightly for the client certificate file to exist after login before
  raising an error.
  [cyberark/conjur-authn-k8s-client#119](cyberark/conjur-authn-k8s-client#119)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants