/
acme_config.go
51 lines (38 loc) · 1.13 KB
/
acme_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package https
import (
"github.com/roadrunner-server/errors"
)
type AcmeConfig struct {
// directory to save the certificates, le_certs default
CacheDir string `mapstructure:"cache_dir"`
// User email, mandatory
Email string `mapstructure:"email"`
// supported values: http-01, tlsalpn-01
ChallengeType string `mapstructure:"challenge_type"`
// The alternate port to use for the ACME HTTP challenge
AltHTTPPort int `mapstructure:"alt_http_port"`
// The alternate port to use for the ACME TLS-ALPN
AltTLSALPNPort int `mapstructure:"alt_tlsalpn_port"`
// Use LE production endpoint or staging
UseProductionEndpoint bool `mapstructure:"use_production_endpoint"`
// Domains to obtain certificates
Domains []string `mapstructure:"domains"`
}
func (ac *AcmeConfig) InitDefaults() error {
if ac.CacheDir == "" {
ac.CacheDir = "rr_cache_dir"
}
if ac.Email == "" {
return errors.Str("email could not be empty")
}
if len(ac.Domains) == 0 {
return errors.Str("should be at least 1 domain")
}
if ac.ChallengeType == "" {
ac.ChallengeType = "http-01"
if ac.AltHTTPPort == 0 {
ac.AltHTTPPort = 80
}
}
return nil
}