|
99 | 99 | ) |
100 | 100 |
|
101 | 101 | // DefaultAutogenValidity is the default validity of a self-signed |
102 | | - // certificate. The value corresponds to 14 months |
103 | | - // (14 months * 30 days * 24 hours). |
104 | | - DefaultAutogenValidity = 14 * 30 * 24 * time.Hour |
| 102 | + // certificate in number of days. |
| 103 | + DefaultAutogenValidity = 365 * 24 * time.Hour |
105 | 104 | ) |
106 | 105 |
|
107 | 106 | type lndConfig struct { |
@@ -146,12 +145,13 @@ type Config struct { |
146 | 145 | Sqlite *loopdb.SqliteConfig `group:"sqlite" namespace:"sqlite"` |
147 | 146 | Postgres *loopdb.PostgresConfig `group:"postgres" namespace:"postgres"` |
148 | 147 |
|
149 | | - TLSCertPath string `long:"tlscertpath" description:"Path to write the TLS certificate for loop's RPC and REST services."` |
150 | | - TLSKeyPath string `long:"tlskeypath" description:"Path to write the TLS private key for loop's RPC and REST services."` |
151 | | - TLSExtraIPs []string `long:"tlsextraip" description:"Adds an extra IP to the generated certificate."` |
152 | | - TLSExtraDomains []string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate."` |
153 | | - TLSAutoRefresh bool `long:"tlsautorefresh" description:"Re-generate TLS certificate and key if the IPs or domains are changed."` |
154 | | - 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."` |
| 148 | + TLSCertPath string `long:"tlscertpath" description:"Path to write the TLS certificate for loop's RPC and REST services."` |
| 149 | + TLSKeyPath string `long:"tlskeypath" description:"Path to write the TLS private key for loop's RPC and REST services."` |
| 150 | + TLSExtraIPs []string `long:"tlsextraip" description:"Adds an extra IP to the generated certificate."` |
| 151 | + TLSExtraDomains []string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate."` |
| 152 | + TLSAutoRefresh bool `long:"tlsautorefresh" description:"Re-generate TLS certificate and key if the IPs or domains are changed."` |
| 153 | + 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."` |
| 154 | + TLSValidity time.Duration `long:"tlsvalidity" description:"Loop's TLS certificate validity period in days. Defaults to 8760h (1 year)"` |
155 | 155 |
|
156 | 156 | MacaroonPath string `long:"macaroonpath" description:"Path to write the macaroon for loop's RPC and REST services if it doesn't exist."` |
157 | 157 |
|
@@ -204,6 +204,7 @@ func DefaultConfig() Config { |
204 | 204 | DebugLevel: defaultLogLevel, |
205 | 205 | TLSCertPath: DefaultTLSCertPath, |
206 | 206 | TLSKeyPath: DefaultTLSKeyPath, |
| 207 | + TLSValidity: DefaultAutogenValidity, |
207 | 208 | MacaroonPath: DefaultMacaroonPath, |
208 | 209 | MaxLSATCost: lsat.DefaultMaxCostSats, |
209 | 210 | MaxLSATFee: lsat.DefaultMaxRoutingFeeSats, |
@@ -348,7 +349,12 @@ func Validate(cfg *Config) error { |
348 | 349 |
|
349 | 350 | // At least one retry. |
350 | 351 | if cfg.MaxPaymentRetries < 1 { |
351 | | - return fmt.Errorf("max payment retries must be positive") |
| 352 | + return fmt.Errorf("max payment retries must be at least 1") |
| 353 | + } |
| 354 | + |
| 355 | + // TLS Validity period to be at least 24 hours |
| 356 | + if cfg.TLSValidity < time.Hour*24 { |
| 357 | + return fmt.Errorf("TLS certificate minimum validity period is 24h") |
352 | 358 | } |
353 | 359 |
|
354 | 360 | return nil |
@@ -415,7 +421,7 @@ func loadCertWithCreate(cfg *Config) (tls.Certificate, *x509.Certificate, |
415 | 421 | certBytes, keyBytes, err := cert.GenCertPair( |
416 | 422 | defaultSelfSignedOrganization, cfg.TLSExtraIPs, |
417 | 423 | cfg.TLSExtraDomains, cfg.TLSDisableAutofill, |
418 | | - DefaultAutogenValidity, |
| 424 | + cfg.TLSValidity, |
419 | 425 | ) |
420 | 426 | if err != nil { |
421 | 427 | return tls.Certificate{}, nil, err |
|
0 commit comments