Skip to content

Commit b56b878

Browse files
authored
Merge pull request #185 from LN-Zap/cert-duration
config: allow tls cert validity duration to be configured
2 parents 9f4a63a + 59a2d5e commit b56b878

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

config.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const (
3030
// we can serve basic functionality by default.
3131
defaultChainConn = false
3232

33-
// DefaultAutogenValidity is the default validity of a self-signed
33+
// defaultTLSCertDuration is the default validity of a self-signed
3434
// certificate. The value corresponds to 14 months
3535
// (14 months * 30 days * 24 hours).
36-
DefaultAutogenValidity = 14 * 30 * 24 * time.Hour
36+
defaultTLSCertDuration = 14 * 30 * 24 * time.Hour
3737
)
3838

3939
var (
@@ -133,12 +133,13 @@ type Config struct { //nolint:maligned
133133
// for all subsystems the same or individual level by subsystem.
134134
DebugLevel string `long:"debuglevel" description:"Debug level for faraday and its subsystems."`
135135

136-
TLSCertPath string `long:"tlscertpath" description:"Path to write the TLS certificate for faraday's RPC and REST services."`
137-
TLSKeyPath string `long:"tlskeypath" description:"Path to write the TLS private key for faraday's RPC and REST services."`
138-
TLSExtraIPs []string `long:"tlsextraip" description:"Adds an extra IP to the generated certificate."`
139-
TLSExtraDomains []string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate."`
140-
TLSAutoRefresh bool `long:"tlsautorefresh" description:"Re-generate TLS certificate and key if the IPs or domains are changed."`
141-
TLSDisableAutofill bool `long:"tlsdisableautofill" description:"Do not include the interface IPs or the system hostname in TLS certificate, use first --tlsextradomain as Common Name instead, if set."`
136+
TLSCertPath string `long:"tlscertpath" description:"Path to write the TLS certificate for faraday's RPC and REST services."`
137+
TLSKeyPath string `long:"tlskeypath" description:"Path to write the TLS private key for faraday's RPC and REST services."`
138+
TLSExtraIPs []string `long:"tlsextraip" description:"Adds an extra IP to the generated certificate."`
139+
TLSExtraDomains []string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate."`
140+
TLSAutoRefresh bool `long:"tlsautorefresh" description:"Re-generate TLS certificate and key if the IPs or domains are changed."`
141+
TLSDisableAutofill bool `long:"tlsdisableautofill" description:"Do not include the interface IPs or the system hostname in TLS certificate, use first --tlsextradomain as Common Name instead, if set."`
142+
TLSCertDuration time.Duration `long:"tlscertduration" description:"The duration for which the auto-generated TLS certificate will be valid for."`
142143

143144
MacaroonPath string `long:"macaroonpath" description:"Path to write the macaroon for faraday's RPC and REST services if it doesn't exist."`
144145

@@ -168,6 +169,7 @@ func DefaultConfig() Config {
168169
DebugLevel: defaultDebugLevel,
169170
TLSCertPath: DefaultTLSCertPath,
170171
TLSKeyPath: DefaultTLSKeyPath,
172+
TLSCertDuration: defaultTLSCertDuration,
171173
MacaroonPath: DefaultMacaroonPath,
172174
RPCListen: defaultRPCListen,
173175
ChainConn: defaultChainConn,
@@ -366,7 +368,7 @@ func loadCertWithCreate(cfg *Config) (tls.Certificate, *x509.Certificate,
366368
certBytes, keyBytes, err := cert.GenCertPair(
367369
defaultSelfSignedOrganization, cfg.TLSExtraIPs,
368370
cfg.TLSExtraDomains, cfg.TLSDisableAutofill,
369-
DefaultAutogenValidity,
371+
cfg.TLSCertDuration,
370372
)
371373
if err != nil {
372374
return tls.Certificate{}, nil, err

0 commit comments

Comments
 (0)