Drop native Let's Encrypt support (#4541)

This commit is contained in:
qwerty287
2024-12-09 19:54:36 +02:00
committed by GitHub
parent 21755bef4e
commit 355ebcd508
8 changed files with 7 additions and 104 deletions

View File

@@ -25,7 +25,6 @@ import (
"strings"
"time"
"github.com/caddyserver/certmagic"
"github.com/gin-gonic/gin"
prometheus_http "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/zerolog"
@@ -167,8 +166,7 @@ func run(ctx context.Context, c *cli.Command) error {
middleware.Store(_store),
)
switch {
case c.String("server-cert") != "":
if c.String("server-cert") != "" {
// start the server with tls enabled
serviceWaitingGroup.Go(func() error {
tlsServer := &http.Server{
@@ -234,32 +232,7 @@ func run(ctx context.Context, c *cli.Command) error {
}
return nil
})
case c.Bool("lets-encrypt"):
// start the server with lets-encrypt
certmagic.DefaultACME.Email = c.String("lets-encrypt-email")
certmagic.DefaultACME.Agreed = true
address, err := url.Parse(strings.TrimSuffix(c.String("server-host"), "/"))
if err != nil {
return err
}
serviceWaitingGroup.Go(func() error {
go func() {
<-ctx.Done()
log.Error().Msg("there is no certmagic.HTTPS alternative who is context aware we will fail in 2 seconds")
time.Sleep(time.Second * 2)
log.Fatal().Msg("we kill certmagic by fail") //nolint:forbidigo
}()
log.Info().Msg("starting certmagic server ...")
if err := certmagic.HTTPS([]string{address.Host}, handler); err != nil {
log.Error().Err(err).Msg("certmagic does not work")
stopServerFunc(fmt.Errorf("certmagic failed: %w", err))
}
return nil
})
default:
} else {
// start the server without tls
serviceWaitingGroup.Go(func() error {
httpServer := &http.Server{