Skip to content

Commit b7d0e57

Browse files
fix: make mTLS client cert loading optional when permission denied
When loading proxy client certificates from env vars, log a warning instead of failing if the files cannot be read (e.g., due to permission denied from k8s-lare cert permissions). This allows the controller to continue with just CA cert verification if mTLS client auth is not strictly required by the proxy. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6c638de commit b7d0e57

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

controllers/actions.github.com/secretresolver/secret_resolver.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ func (sr *SecretResolver) addProxyCACertsToPool(ctx context.Context, namespace s
513513

514514
// loadProxyTLSClientCertsFromEnv loads TLS client certificates from file paths specified in env vars.
515515
// Used when proxy is set via HTTPS_PROXY env var instead of CR config.
516+
// If files cannot be read (e.g., permission denied), logs a warning and continues without mTLS client cert.
516517
func (sr *SecretResolver) loadProxyTLSClientCertsFromEnv() ([]tls.Certificate, error) {
517518
var certs []tls.Certificate
518519

@@ -521,7 +522,10 @@ func (sr *SecretResolver) loadProxyTLSClientCertsFromEnv() ([]tls.Certificate, e
521522
if certFile != "" && keyFile != "" {
522523
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
523524
if err != nil {
524-
return nil, fmt.Errorf("failed to load client cert from files (cert=%s, key=%s): %w", certFile, keyFile, err)
525+
// Log warning but don't fail - mTLS client cert may be optional for some proxies
526+
sr.logger.Warn("Could not load proxy client cert from env var file paths, continuing without mTLS client cert",
527+
"cert", certFile, "key", keyFile, "error", err)
528+
return certs, nil
525529
}
526530
certs = append(certs, cert)
527531
sr.logger.Info("Loaded proxy client cert from env var file paths", "cert", certFile, "key", keyFile)

0 commit comments

Comments
 (0)