1 parent
519e2b4a5f
commit
d7837de561
45 files changed
+1588
-109
No files matched your search
@@ -12,6 +12,7 @@ import (
|
||||
"git.pcux.cn/xuans/Smail/signal"
|
||||
"git.pcux.cn/xuans/Smail/utils/async"
|
||||
"git.pcux.cn/xuans/Smail/utils/errors"
|
||||
"git.pcux.cn/xuans/Smail/utils/runtimepath"
|
||||
"github.com/go-acme/lego/v4/certificate"
|
||||
"github.com/go-acme/lego/v4/challenge/dns01"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -116,7 +117,7 @@ func SetSSL(sslType, priKey, crtKey string) error {
|
||||
cfg.SSL = config.SSLConfig{
|
||||
Management: config.SSLManagementProject,
|
||||
Mode: config.ManagedSSLModeDefault,
|
||||
DefaultDirectory: "data/ssl",
|
||||
DefaultDirectory: runtimepath.SSLReference(config.ROOT_PATH, "data/ssl"),
|
||||
}
|
||||
if cfg.SSLType == config.SSLTypeAutoDNS {
|
||||
cfg.SSL.Challenge = config.SSLChallengeDNS
|
||||
@@ -190,12 +191,12 @@ func applyManagedSSLReference(cfg *config.Config, reference config.ManagedSSLRef
|
||||
cfg.SSL = config.SSLConfig{
|
||||
Management: management,
|
||||
Mode: reference.Mode,
|
||||
DefaultDirectory: "data/ssl",
|
||||
DefaultDirectory: runtimepath.SSLReference(config.ROOT_PATH, "data/ssl"),
|
||||
CertificateRef: reference.CertificateRef,
|
||||
PrivateKeyRef: reference.PrivateKeyRef,
|
||||
}
|
||||
if reference.Mode == config.ManagedSSLModeUpload {
|
||||
cfg.SSL.CustomDirectory = "data/ssl/managed/upload"
|
||||
cfg.SSL.CustomDirectory = runtimepath.SSLReference(config.ROOT_PATH, "data/ssl/managed/upload")
|
||||
} else if cfg.SSLType == config.SSLTypeAutoDNS {
|
||||
cfg.SSL.Challenge = config.SSLChallengeDNS
|
||||
} else {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"git.pcux.cn/xuans/Smail/config"
|
||||
"git.pcux.cn/xuans/Smail/utils/atomicfile"
|
||||
securefile "git.pcux.cn/xuans/Smail/utils/file"
|
||||
"git.pcux.cn/xuans/Smail/utils/runtimepath"
|
||||
)
|
||||
|
||||
func writeCertificateBundle(cfg *config.Config, privateKey, certificate, issuer []byte) error {
|
||||
@@ -31,7 +32,7 @@ func writeCertificateBundle(cfg *config.Config, privateKey, certificate, issuer
|
||||
return err
|
||||
}
|
||||
defer workspaceRoot.Close()
|
||||
baseRelative := filepath.Join("data", "ssl")
|
||||
baseRelative := filepath.FromSlash(runtimepath.SSLReference(rootPath, "data/ssl"))
|
||||
if err := ensureSecureRootDirectory(workspaceRoot, baseRelative); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -57,7 +58,7 @@ func writeCertificateBundle(cfg *config.Config, privateKey, certificate, issuer
|
||||
}
|
||||
relativePath, err := securefile.ControlledRelativePath(basePath, item.path)
|
||||
if err != nil {
|
||||
return errors.New("SSL file path must stay inside data/ssl")
|
||||
return errors.New("证书文件必须位于受保护的 SSL 目录中")
|
||||
}
|
||||
if _, exists := seen[relativePath]; exists {
|
||||
return errors.New("SSL file paths must be unique")
|
||||
|
||||
Reference in new issue
Block a user