Skip to content

Commit 4490fee

Browse files
ycombinatorclaude
andauthored
Remove manual CertReloader wiring (#6946)
* Remove manual CertReloader wiring from server LoadTLSServerConfig in elastic-agent-libs now handles CertReloader setup internally (elastic/elastic-agent-libs#417), making the manual wiring in server.go redundant. This also removes the local resolvePassphrase helper which is now handled by the library. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Remove trailing blank line from server.go Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 11bb5ee commit 4490fee

1 file changed

Lines changed: 0 additions & 39 deletions

File tree

internal/pkg/api/server.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
slog "log"
1313
"net"
1414
"net/http"
15-
"os"
1615

1716
"github.com/elastic/elastic-agent-libs/logp"
1817
"github.com/elastic/elastic-agent-libs/transport/tlscommon"
@@ -120,30 +119,6 @@ func (s *server) Run(ctx context.Context) error {
120119
// (see https://golang.org/pkg/net/http/#Server.Serve)
121120
srv.TLSConfig.NextProtos = []string{"h2", "http/1.1"}
122121

123-
if s.cfg.TLS.CertificateReload.IsEnabled() {
124-
var opts []tlscommon.CertReloaderOption
125-
if s.cfg.TLS.CertificateReload.ReloadInterval > 0 {
126-
opts = append(opts, tlscommon.WithReloadInterval(s.cfg.TLS.CertificateReload.ReloadInterval))
127-
}
128-
passphrase, err := resolvePassphrase(s.cfg.TLS.Certificate)
129-
if err != nil {
130-
return fmt.Errorf("failed to resolve TLS key passphrase: %w", err)
131-
}
132-
if passphrase != "" {
133-
opts = append(opts, tlscommon.WithPassphrase(passphrase))
134-
}
135-
reloader, err := tlscommon.NewCertReloader(
136-
s.cfg.TLS.Certificate.Certificate,
137-
s.cfg.TLS.Certificate.Key,
138-
opts...,
139-
)
140-
if err != nil {
141-
return fmt.Errorf("failed to initialize TLS cert reloader: %w", err)
142-
}
143-
srv.TLSConfig.GetCertificate = reloader.GetCertificate
144-
srv.TLSConfig.Certificates = nil
145-
}
146-
147122
ln = tls.NewListener(ln, srv.TLSConfig)
148123

149124
} else {
@@ -246,17 +221,3 @@ func wrapConnLimitter(ctx context.Context, ln net.Listener, cfg *config.Server)
246221

247222
return ln
248223
}
249-
250-
func resolvePassphrase(cert tlscommon.CertificateConfig) (string, error) {
251-
if cert.Passphrase != "" {
252-
return cert.Passphrase, nil
253-
}
254-
if cert.PassphrasePath != "" {
255-
p, err := os.ReadFile(cert.PassphrasePath)
256-
if err != nil {
257-
return "", fmt.Errorf("unable to read key passphrase file: %w", err)
258-
}
259-
return string(p), nil
260-
}
261-
return "", nil
262-
}

0 commit comments

Comments
 (0)