Add redis for caching, first try during a train ride so expect it to not be working yet

This commit is contained in:
Moritz Marquardt 2024-03-24 20:24:32 +01:00
parent b8b9886ee1
commit 5b6eecc75f
12 changed files with 149 additions and 32 deletions

View file

@ -60,12 +60,12 @@ func SetupHTTPACMEChallengeServer(challengeCache cache.ICache, sslPort uint) htt
// it's an acme request
if strings.HasPrefix(ctx.Path(), challengePath) {
challenge, ok := challengeCache.Get(domain + "/" + strings.TrimPrefix(ctx.Path(), challengePath))
if !ok || challenge == nil {
if !ok || challenge == "" {
log.Info().Msgf("HTTP-ACME challenge for '%s' failed: token not found", domain)
ctx.String("no challenge for this token", http.StatusNotFound)
}
log.Info().Msgf("HTTP-ACME challenge for '%s' succeeded", domain)
ctx.String(challenge.(string))
ctx.String(challenge)
return
}

View file

@ -6,6 +6,7 @@ import (
"crypto/x509"
"errors"
"fmt"
"github.com/OrlovEvgeny/go-mcache"
"strconv"
"strings"
"time"
@ -31,7 +32,7 @@ func TLSConfig(mainDomainSuffix string,
giteaClient *gitea.Client,
acmeClient *AcmeClient,
firstDefaultBranch string,
keyCache, challengeCache, dnsLookupCache, canonicalDomainCache cache.ICache,
keyCache *mcache.CacheDriver, challengeCache cache.ICache, dnsLookupCache *mcache.CacheDriver, canonicalDomainCache cache.ICache,
certDB database.CertDB,
noDNS01 bool,
rawDomain string,
@ -56,7 +57,7 @@ func TLSConfig(mainDomainSuffix string,
if !ok {
return nil, errors.New("no challenge for this domain")
}
cert, err := tlsalpn01.ChallengeCert(domain, challenge.(string))
cert, err := tlsalpn01.ChallengeCert(domain, challenge)
if err != nil {
return nil, err
}