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

🌱 Add support for SSL env vars to cert pool watcher #1672

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

tmshort
Copy link
Contributor

@tmshort tmshort commented Jan 30, 2025

The SystemRoot store looks at the SSL_CERT_DIR and SSL_CERT_FILE environment variables for certificate locations. Because these variables are under control of the user, we should assume that the user wants to control the contents of the SystemRoot, and subsequently that those contents could change (as compared to certs located in the default /etc/pki location).

Thus, we should watch those locations if they exist.

@tmshort tmshort requested a review from a team as a code owner January 30, 2025 15:30
Copy link

netlify bot commented Jan 30, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit b6b2355
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/679be7242fd1e2000840e2fd
😎 Deploy Preview https://deploy-preview-1672--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review.

Project coverage is 67.49%. Comparing base (158d974) to head (b6b2355).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
internal/httputil/certpoolwatcher.go 78.57% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1672      +/-   ##
==========================================
+ Coverage   67.42%   67.49%   +0.07%     
==========================================
  Files          55       57       +2     
  Lines        4632     4630       -2     
==========================================
+ Hits         3123     3125       +2     
+ Misses       1284     1278       -6     
- Partials      225      227       +2     
Flag Coverage Δ
e2e 53.37% <57.14%> (+0.07%) ⬆️
unit 54.31% <57.14%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

camilamacedo86
camilamacedo86 previously approved these changes Jan 30, 2025
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2025
// specified, this means that we have some control over the system root
// location, thus they may change, thus we should watch those locations.
if d := os.Getenv("SSL_CERT_DIR"); d != "" {
dirs := strings.Split(d, ":")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dirs := strings.Split(d, ":")
dirs := filepath.SplitList(d)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The separater is explicitly ":", and this is exactly how the golang library crypto/x509 does it, so I'm a bit reluctant to change it.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, if crypto/x509 does it with simple strings.Split, I'm good.

if err = watcher.Add(f); err != nil {
return nil, err
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: collect the paths in step 1, slices.DeleteFunc to stat and remove in step 2, loop over remaining to call watcher.Add in step 3?

Copy link
Member

Choose a reason for hiding this comment

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

watchPaths := []string{caDir, os.Getenv("SSL_CERT_DIR"), os.Getenv("SSL_CERT_FILE")}

slices.DeleteFunc(watchPaths, func(p string) bool { /* do stat here */})

for _, p := range watchPaths {
    if err := watcher.Add(p); err != nil {
        return nil, err
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting...

The SystemRoot store looks at the SSL_CERT_DIR and SSL_CERT_FILE
environment variables for certificate locations. Because these
variables are under control of the user, we should assume that
the user wants to control the contents of the SystemRoot, and
subsequently that those contents could change (as compared to certs
located in the default /etc/pki location).

Thus, we should watch those locations if they exist.

Signed-off-by: Todd Short <[email protected]>
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2025
Copy link

openshift-ci bot commented Jan 30, 2025

New changes are detected. LGTM label has been removed.

@joelanford joelanford enabled auto-merge January 30, 2025 21:08
@joelanford joelanford added this pull request to the merge queue Jan 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2025
@tmshort tmshort added this pull request to the merge queue Jan 30, 2025
Merged via the queue into operator-framework:main with commit 04f1b93 Jan 30, 2025
22 checks passed
@tmshort tmshort deleted the cert-pool branch January 30, 2025 21:40
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.

3 participants