- 
                Notifications
    You must be signed in to change notification settings 
- Fork 35
OCPBUGS-49860: Fix certificate issues #260
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      4a2d421
              
                UPSTREAM: <carry>: use projected volume for CAs to avoid subPath limi…
              
              
                joelanford 016f490
              
                UPSTREAM: <drop>: Add support for SSL env vars to cert pool watcher (…
              
              
                tmshort cc32b33
              
                UPSTREAM: <drop>: Separate CA configuration for pulls vs catalogd ser…
              
              
                tmshort 8acad52
              
                UPSTREAM: <drop>: Add logging to certpoolwatcher and client
              
              
                tmshort File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package httputil | ||
|  | ||
| import ( | ||
| "crypto/x509" | ||
| "encoding/pem" | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
|  | ||
| "github.com/go-logr/logr" | ||
| ) | ||
|  | ||
| func logPath(path, action string, log logr.Logger) { | ||
| fi, err := os.Stat(path) | ||
| if err != nil { | ||
| log.Error(err, "error in os.Stat()", "path", path) | ||
| return | ||
| } | ||
| if !fi.IsDir() { | ||
| logFile(path, "", fmt.Sprintf("%s file", action), log) | ||
| return | ||
| } | ||
| action = fmt.Sprintf("%s directory", action) | ||
| dirEntries, err := os.ReadDir(path) | ||
| if err != nil { | ||
| log.Error(err, "error in os.ReadDir()", "path", path) | ||
| return | ||
| } | ||
| for _, e := range dirEntries { | ||
| file := filepath.Join(path, e.Name()) | ||
| fi, err := os.Stat(file) | ||
| if err != nil { | ||
| log.Error(err, "error in os.Stat()", "file", file) | ||
| continue | ||
| } | ||
| if fi.IsDir() { | ||
| log.Info("ignoring subdirectory", "directory", file) | ||
| continue | ||
| } | ||
| logFile(e.Name(), path, action, log) | ||
| } | ||
| } | ||
|  | ||
| func logFile(filename, path, action string, log logr.Logger) { | ||
| filepath := filepath.Join(path, filename) | ||
| data, err := os.ReadFile(filepath) | ||
| if err != nil { | ||
| log.Error(err, "error in os.ReadFile()", "file", filename) | ||
| return | ||
| } | ||
| logPem(data, filename, path, action, log) | ||
| } | ||
|  | ||
| func logPem(data []byte, filename, path, action string, log logr.Logger) { | ||
| for len(data) > 0 { | ||
| var block *pem.Block | ||
| block, data = pem.Decode(data) | ||
| if block == nil { | ||
| log.Info("error: no block returned from pem.Decode()", "file", filename) | ||
| return | ||
| } | ||
| crt, err := x509.ParseCertificate(block.Bytes) | ||
| if err != nil { | ||
| log.Error(err, "error in x509.ParseCertificate()", "file", filename) | ||
| return | ||
| } | ||
|  | ||
| args := []any{} | ||
| if path != "" { | ||
| args = append(args, "directory", path) | ||
| } | ||
| // Find an appopriate certificate identifier | ||
| args = append(args, "file", filename) | ||
| if s := crt.Subject.String(); s != "" { | ||
| args = append(args, "subject", s) | ||
| } else if crt.DNSNames != nil { | ||
| args = append(args, "DNSNames", crt.DNSNames) | ||
| } else if s := crt.SerialNumber.String(); s != "" { | ||
| args = append(args, "serial", s) | ||
| } | ||
| log.Info(action, args...) | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            16 changes: 5 additions & 11 deletions
          
          16 
        
  ...hift/catalogd/kustomize/overlays/openshift/olmv1-ns/patches/manager_deployment_certs.yaml
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,27 +1,21 @@ | ||
| - op: add | ||
| path: /spec/template/spec/volumes/- | ||
| value: {"name":"catalogserver-certs", "secret":{"optional":false,"secretName":"catalogserver-cert"}} | ||
| value: {"name":"catalogserver-certs", "secret":{"optional":false,"secretName":"catalogserver-cert","items":[{"key":"tls.crt","path":"tls.crt"},{"key":"tls.key","path":"tls.key"}]}} | ||
| - op: add | ||
| path: /spec/template/spec/volumes/- | ||
| value: {"name":"trusted-ca-bundle", "configMap":{"optional":false,"name":"trusted-ca-bundle", "items":[{"key":"ca-bundle.crt","path":"ca-bundle.crt"}]}} | ||
| - op: add | ||
| path: /spec/template/spec/volumes/- | ||
| value: {"name":"service-ca", "configMap":{"optional":false,"name":"openshift-service-ca.crt", "items":[{"key":"service-ca.crt","path":"service-ca.crt"}]}} | ||
| value: {"name":"ca-certs", "projected": {"sources":[{"configMap":{"optional":false,"name":"trusted-ca-bundle", "items":[{"key":"ca-bundle.crt","path":"ca-bundle.crt"}]}},{"configMap":{"optional":false,"name":"openshift-service-ca.crt", "items":[{"key":"service-ca.crt","path":"service-ca.crt"}]}}]}} | ||
| - op: add | ||
| path: /spec/template/spec/containers/0/volumeMounts/- | ||
| value: {"name":"catalogserver-certs", "mountPath":"/var/certs"} | ||
| - op: add | ||
| path: /spec/template/spec/containers/0/volumeMounts/- | ||
| value: {"name":"trusted-ca-bundle", "mountPath":"/var/trusted-cas/ca-bundle.crt", "subPath":"ca-bundle.crt"} | ||
| - op: add | ||
| path: /spec/template/spec/containers/0/volumeMounts/- | ||
| value: {"name":"service-ca", "mountPath":"/var/trusted-cas/service-ca.crt", "subPath":"service-ca.crt"} | ||
| value: {"name":"ca-certs", "mountPath":"/var/ca-certs", "readOnly": true} | ||
| - op: add | ||
| path: /spec/template/spec/containers/0/args/- | ||
| value: "--tls-cert=/var/certs/tls.crt" | ||
| - op: add | ||
| path: /spec/template/spec/containers/0/args/- | ||
| value: "--tls-key=/var/certs/tls.key" | ||
| - op: add | ||
| path: /spec/template/spec/containers/0/args/- | ||
| value: "--ca-certs-dir=/var/trusted-cas" | ||
| path: /spec/template/spec/containers/0/env | ||
| value: [{"name":"SSL_CERT_DIR", "value":"/var/ca-certs"}] | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.