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

Don't ignore system cert error #1132

Merged

Conversation

absoludity
Copy link
Contributor

Following up on a comment https://github.com/kubeapps/kubeapps/pull/1125/files#r315253073 this ensures that we don't swallow an error unnecessarily when getting the system certs.

So that I don't break anyone's test environment, an empty pool of certs can be explicitly allowed if necessary.

@absoludity absoludity requested a review from andresmgot August 21, 2019 00:34
caCertPool = x509.NewCertPool()
caCertPool := x509.NewCertPool()
// Get the SystemCertPool unless the env var is explicitly set.
if _, ok := os.LookupEnv("TILLER_PROXY_ALLOW_EMPTY_CERT_POOL"); !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would do it a bit different, mostly because TILLER_PROXY_ALLOW_EMPTY_CERT_POOL suggest for me that it's going to at least try to load the cert pool:

	caCertPool, err := x509.SystemCertPool()
	if err != nil {
          if _, ok := os.LookupEnv("TILLER_PROXY_ALLOW_EMPTY_CERT_POOL"); !ok {
            return nil, err
          }
          caCertPool = x509.NewCertPool()
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I had it that way first, but then the optimizing demon in my head wondered whether SystemCertPool() is more expensive (ie. whether NewCertPool() is just a memory allocation. But you're right in that it's premature... the code is clearer when it matches the env var. Switched.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This required removing the tests I'd added too - as I can't force or mock x509.SystemCertPool() easily (runtime.GOOS is a const). Not sure it matters.

@andresmgot andresmgot merged commit 662e39b into vmware-tanzu:master Aug 22, 2019
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.

2 participants