mirror of
https://github.com/foomo/simplecert.git
synced 2025-10-16 12:35:34 +00:00
improve config validation
This commit is contained in:
parent
f8617e41f6
commit
b441d911f8
26
config.go
26
config.go
@ -18,11 +18,15 @@ import (
|
||||
var (
|
||||
c *Config
|
||||
|
||||
errNoDirectoryURL = errors.New("simplecert: no directory url specified")
|
||||
errNoMail = errors.New("simplecert: no SSLEmail in config")
|
||||
errNoDomains = errors.New("simplecert: no domains specified")
|
||||
errNoChallenge = errors.New("simplecert: no challenge method specified")
|
||||
errNoCacheDir = errors.New("simplecert: no cache directory specified")
|
||||
errNoDirectoryURL = errors.New("simplecert: no directory url specified in config")
|
||||
errNoMail = errors.New("simplecert: no SSLEmail in config in config")
|
||||
errNoDomains = errors.New("simplecert: no domains specified in config")
|
||||
errNoChallenge = errors.New("simplecert: no challenge method specified in config")
|
||||
errNoCacheDir = errors.New("simplecert: no cache directory specified in config")
|
||||
|
||||
errNoRenewBefore = errors.New("simplecert: no renew before value set in config")
|
||||
errNoCheckInterval = errors.New("simplecert: no check interval set in config")
|
||||
errNoCacheDirPerm = errors.New("simplecert: no cache directory permission specified in config")
|
||||
)
|
||||
|
||||
// Default contains a default configuration
|
||||
@ -116,6 +120,18 @@ func CheckConfig(c *Config) error {
|
||||
return errNoChallenge
|
||||
}
|
||||
|
||||
if c.RenewBefore == 0 {
|
||||
return errNoCacheDir
|
||||
}
|
||||
|
||||
if c.CheckInterval == 0 {
|
||||
return errNoCheckInterval
|
||||
}
|
||||
|
||||
if c.CacheDirPerm == 0 {
|
||||
return errNoCacheDirPerm
|
||||
}
|
||||
|
||||
if c.WillRenewCertificate == nil && (c.HTTPAddress != "" || c.TLSAddress != "") {
|
||||
log.Println("[WARNING] no WillRenewCertificate handler specified, to handle graceful server shutdown!")
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user