feat: retain encrypted instance credentials and reissue v2 certificates
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
@@ -11,14 +11,15 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
HTTPAddr string
|
||||
TrustedProxies []string
|
||||
ReadHeaderTimeout time.Duration
|
||||
ReadTimeout time.Duration
|
||||
WriteTimeout time.Duration
|
||||
IdleTimeout time.Duration
|
||||
ShutdownTimeout time.Duration
|
||||
SigningPrivateKeyPEM string
|
||||
HTTPAddr string
|
||||
TrustedProxies []string
|
||||
ReadHeaderTimeout time.Duration
|
||||
ReadTimeout time.Duration
|
||||
WriteTimeout time.Duration
|
||||
IdleTimeout time.Duration
|
||||
ShutdownTimeout time.Duration
|
||||
SigningPrivateKeyPEM string
|
||||
CredentialEncryptionKey []byte
|
||||
}
|
||||
|
||||
func Load(getenv func(string) string) (Config, error) {
|
||||
@@ -85,6 +86,16 @@ func Load(getenv func(string) string) (Config, error) {
|
||||
}
|
||||
c.SigningPrivateKeyPEM = string(data)
|
||||
}
|
||||
if path := getenv("LICENSE_CREDENTIAL_ENCRYPTION_KEY_FILE"); path != "" {
|
||||
if !filepath.IsAbs(path) {
|
||||
return Config{}, fmt.Errorf("credential encryption key path must be absolute")
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil || len(data) != 32 {
|
||||
return Config{}, fmt.Errorf("credential encryption key must be exactly 32 raw bytes")
|
||||
}
|
||||
c.CredentialEncryptionKey = data
|
||||
}
|
||||
if root := getenv("PACKAGE_STORAGE_ROOT"); root != "" {
|
||||
if !filepath.IsAbs(root) {
|
||||
return Config{}, fmt.Errorf("PACKAGE_STORAGE_ROOT must be absolute")
|
||||
|
||||
Reference in New Issue
Block a user