feat: domain config add disable follow CNAME #228

This commit is contained in:
PBK-B 2024-10-20 23:27:42 +08:00
parent ec6f10053a
commit 2c75d2bfde
2 changed files with 29 additions and 17 deletions

View File

@ -7,6 +7,7 @@ import (
"crypto/rand" "crypto/rand"
"errors" "errors"
"fmt" "fmt"
"os"
"strings" "strings"
"github.com/usual2970/certimate/internal/domain" "github.com/usual2970/certimate/internal/domain"
@ -63,12 +64,13 @@ type Certificate struct {
} }
type ApplyOption struct { type ApplyOption struct {
Email string `json:"email"` Email string `json:"email"`
Domain string `json:"domain"` Domain string `json:"domain"`
Access string `json:"access"` Access string `json:"access"`
KeyAlgorithm string `json:"keyAlgorithm"` KeyAlgorithm string `json:"keyAlgorithm"`
Nameservers string `json:"nameservers"` Nameservers string `json:"nameservers"`
Timeout int64 `json:"timeout"` Timeout int64 `json:"timeout"`
DisableFollowCNAME bool `json:"disableFollowCNAME"`
} }
type ApplyUser struct { type ApplyUser struct {
@ -115,12 +117,13 @@ func Get(record *models.Record) (Applicant, error) {
} }
option := &ApplyOption{ option := &ApplyOption{
Email: applyConfig.Email, Email: applyConfig.Email,
Domain: record.GetString("domain"), Domain: record.GetString("domain"),
Access: access.GetString("config"), Access: access.GetString("config"),
KeyAlgorithm: applyConfig.KeyAlgorithm, KeyAlgorithm: applyConfig.KeyAlgorithm,
Nameservers: applyConfig.Nameservers, Nameservers: applyConfig.Nameservers,
Timeout: applyConfig.Timeout, Timeout: applyConfig.Timeout,
DisableFollowCNAME: applyConfig.DisableFollowCNAME,
} }
switch access.GetString("configType") { switch access.GetString("configType") {
@ -177,6 +180,14 @@ func apply(option *ApplyOption, provider challenge.Provider) (*Certificate, erro
return nil, err return nil, err
} }
// Some unified lego environment variables are configured here.
disableFCNAME := "false"
if option.DisableFollowCNAME {
disableFCNAME = "true"
}
// link: https://github.com/go-acme/lego/issues/1867
os.Setenv("LEGO_DISABLE_CNAME_SUPPORT", disableFCNAME)
myUser := ApplyUser{ myUser := ApplyUser{
Email: option.Email, Email: option.Email,
key: privateKey, key: privateKey,

View File

@ -1,11 +1,12 @@
package domain package domain
type ApplyConfig struct { type ApplyConfig struct {
Email string `json:"email"` Email string `json:"email"`
Access string `json:"access"` Access string `json:"access"`
KeyAlgorithm string `json:"keyAlgorithm"` KeyAlgorithm string `json:"keyAlgorithm"`
Nameservers string `json:"nameservers"` Nameservers string `json:"nameservers"`
Timeout int64 `json:"timeout"` Timeout int64 `json:"timeout"`
DisableFollowCNAME bool `json:"disableFollowCNAME"`
} }
type DeployConfig struct { type DeployConfig struct {