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" "crypto/x509/pkix"
"errors" "errors"
"fmt" "fmt"
"net/http"
"time" "time"
"github.com/getprobo/probo/pkg/crypto/keys" "github.com/getprobo/probo/pkg/crypto/keys"
@@ -66,8 +65,8 @@ func NewACMEService(
email string, email string,
keyType keys.Type, keyType keys.Type,
directoryURL string, directoryURL string,
insecureTLS bool,
accountKey crypto.Signer, accountKey crypto.Signer,
rootCAs *x509.CertPool,
logger *log.Logger, logger *log.Logger,
) (*ACMEService, error) { ) (*ACMEService, error) {
if accountKey == nil { 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") logger.Warn("no account key provided, generating new ACME account - this will create a new account on each restart")
} }
var httpClient *http.Client httpClientOpts := []httpclient.Option{
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), 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{ client := &acme.Client{
Key: accountKey, Key: accountKey,
DirectoryURL: directoryURL, DirectoryURL: directoryURL,

View File

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

View File

@@ -18,6 +18,7 @@ import (
"context" "context"
"crypto" "crypto"
"crypto/tls" "crypto/tls"
"crypto/x509"
"errors" "errors"
"fmt" "fmt"
"net" "net"
@@ -267,12 +268,20 @@ func (impl *Implm) Run(
l.Info("using configured ACME account key") 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( acmeService, err := certmanager.NewACMEService(
impl.cfg.CustomDomains.ACME.Email, impl.cfg.CustomDomains.ACME.Email,
keys.Type(impl.cfg.CustomDomains.ACME.KeyType), keys.Type(impl.cfg.CustomDomains.ACME.KeyType),
impl.cfg.CustomDomains.ACME.Directory, impl.cfg.CustomDomains.ACME.Directory,
impl.cfg.CustomDomains.ACME.InsecureTLS,
accountKey, accountKey,
rootCAs,
l, l,
) )
if err != nil { if err != nil {