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

*: watch tls certificate changes #47

Merged
merged 1 commit into from
Jun 20, 2019
Merged

Conversation

s-urbaniak
Copy link
Collaborator

TODOs:

  • check on a running cluster

This is an implementation as discussed in #45 (comment), ready for an initial pass.

I am keeping the other PR open to scavenge the code for the prometheus config reloader implementation.

@s-urbaniak
Copy link
Collaborator Author

/cc @brancz @metalmatze @paulfantom

Copy link
Owner

@brancz brancz left a comment

Choose a reason for hiding this comment

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

Just two small comments otherwise overall looks good!


var err error

crt, err := ioutil.ReadFile(r.certPath)
Copy link
Owner

Choose a reason for hiding this comment

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

Unlikely but I think we should check both errors here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, doh, i wanted to achieve a running err check, silly me, i'll add an err check here too obviously, good catch 👍

}

h := fnv.New64a()
_, err = h.Write(crt)
Copy link
Owner

Choose a reason for hiding this comment

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

Is hashing really necessary? Seems like we should just be able to compare the bytes of the certs themselves.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sounds good 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

small complication, I rechecked, and the parsing function stores DEM bytes as per https://golang.org/src/crypto/tls/tls.go?s=6337:6408#L193, so comparing the raw file content is not applicable.

Does comparing the https://golang.org/pkg/crypto/tls/#Certificate.Certificate slice after parsing sound good to you?

Copy link
Owner

Choose a reason for hiding this comment

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

Can’t we save the raw content bytes in the same fashion as we do the hash right now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we definitely can, i'll add that 👍

@s-urbaniak
Copy link
Collaborator Author

@brancz addressed comments, PTAL

Copy link
Owner

@brancz brancz left a comment

Choose a reason for hiding this comment

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

We’re very close, just a small nit around the lock granularity.

}

func (r *CertReloader) reload() error {
r.mu.Lock()
Copy link
Owner

Choose a reason for hiding this comment

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

This lock seems a little excessive, let’s just lock around the actual replacement, once we’ve ensured we really do need to replace and just read lock around reading the “current” cert bytes (as in the if statement doing bytes.Equal)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ack, i've been thinking the same, but reasoned that this locks once per minute, on average. agreed on the finer granularity 👍

Copy link
Owner

Choose a reason for hiding this comment

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

if this was just for exporters I'd be fine with that, but we're guarding Prometheus with this, which gets frequent query requests, so I'd prefer to do this at this point already

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's perfectly reasonable, addressed, ptal

@brancz
Copy link
Owner

brancz commented Jun 20, 2019

lgtm 👍

@brancz brancz merged commit 0ddd432 into brancz:master Jun 20, 2019
@s-urbaniak s-urbaniak deleted the tls-reload-tick branch June 20, 2019 08:45
s-urbaniak pushed a commit to s-urbaniak/kube-rbac-proxy that referenced this pull request Jun 28, 2021
…rator.yaml-`build_root_image`-from-openshift/release

Updating .ci-operator.yaml `build_root_image` from openshift/release
ibihim pushed a commit to ibihim/kube-rbac-proxy that referenced this pull request Oct 20, 2022
loosen up username and identity name validation
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

2 participants