Remove insecure acme option

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-10-03 13:56:04 +02:00
parent 0076b6eb91
commit 26c7364e27
3 changed files with 29 additions and 24 deletions

View File

@@ -23,7 +23,6 @@ import (
"crypto/x509/pkix"
"errors"
"fmt"
"net/http"
"time"
"github.com/getprobo/probo/pkg/crypto/keys"
@@ -66,8 +65,8 @@ func NewACMEService(
email string,
keyType keys.Type,
directoryURL string,
insecureTLS bool,
accountKey crypto.Signer,
rootCAs *x509.CertPool,
logger *log.Logger,
) (*ACMEService, error) {
if accountKey == nil {
@@ -80,24 +79,21 @@ func NewACMEService(
logger.Warn("no account key provided, generating new ACME account - this will create a new account on each restart")
}
var httpClient *http.Client
if insecureTLS {
transport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
httpClient = &http.Client{
Transport: transport,
Timeout: 30 * time.Second,
}
logger.Warn("ACME service configured with insecure TLS - use only for local testing")
} else {
httpClient = httpclient.DefaultPooledClient(
httpclient.WithLogger(logger),
)
httpClientOpts := []httpclient.Option{
httpclient.WithLogger(logger),
}
if rootCAs != nil {
httpClientOpts = append(
httpClientOpts,
httpclient.WithTLSConfig(&tls.Config{RootCAs: rootCAs}),
)
logger.Info("ACME service configured with custom root CA")
}
httpClient := httpclient.DefaultPooledClient(httpClientOpts...)
client := &acme.Client{
Key: accountKey,
DirectoryURL: directoryURL,

View File

@@ -22,9 +22,9 @@ type customDomainsConfig struct {
}
type acmeConfig struct {
Directory string `json:"directory"`
Email string `json:"email"`
KeyType string `json:"key-type"`
InsecureTLS bool `json:"insecure-tls"`
AccountKey string `json:"account-key"`
Directory string `json:"directory"`
Email string `json:"email"`
KeyType string `json:"key-type"`
AccountKey string `json:"account-key"`
RootCA string `json:"root-ca"`
}

View File

@@ -18,6 +18,7 @@ import (
"context"
"crypto"
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"net"
@@ -267,12 +268,20 @@ func (impl *Implm) Run(
l.Info("using configured ACME account key")
}
var rootCAs *x509.CertPool
if impl.cfg.CustomDomains.ACME.RootCA != "" {
rootCAs = x509.NewCertPool()
if !rootCAs.AppendCertsFromPEM([]byte(impl.cfg.CustomDomains.ACME.RootCA)) {
return fmt.Errorf("failed to parse ACME root CA certificate")
}
}
acmeService, err := certmanager.NewACMEService(
impl.cfg.CustomDomains.ACME.Email,
keys.Type(impl.cfg.CustomDomains.ACME.KeyType),
impl.cfg.CustomDomains.ACME.Directory,
impl.cfg.CustomDomains.ACME.InsecureTLS,
accountKey,
rootCAs,
l,
)
if err != nil {