fix(settings): read PEM files but b64 env vars
- Extract base64 data from PEM files and secret files - Environment variables are not PEM encoded and only the base64 data - Affects OpenVPN certificate, key and encrypted key
This commit is contained in:
25
internal/configuration/sources/env/openvpn.go
vendored
25
internal/configuration/sources/env/openvpn.go
vendored
@@ -30,15 +30,8 @@ func (r *Reader) readOpenVPN() (
|
||||
openVPN.Auth = &auth
|
||||
}
|
||||
|
||||
openVPN.ClientCrt, err = readBase64OrNil("OPENVPN_CLIENTCRT")
|
||||
if err != nil {
|
||||
return openVPN, fmt.Errorf("environment variable OPENVPN_CLIENTCRT: %w", err)
|
||||
}
|
||||
|
||||
openVPN.ClientKey, err = readBase64OrNil("OPENVPN_CLIENTKEY")
|
||||
if err != nil {
|
||||
return openVPN, fmt.Errorf("environment variable OPENVPN_CLIENTKEY: %w", err)
|
||||
}
|
||||
openVPN.ClientCrt = envToStringPtr("OPENVPN_CLIENTCRT")
|
||||
openVPN.ClientKey = envToStringPtr("OPENVPN_CLIENTKEY")
|
||||
|
||||
openVPN.PIAEncPreset = r.readPIAEncryptionPreset()
|
||||
|
||||
@@ -83,20 +76,6 @@ func (r *Reader) readOpenVPNPassword() (password string) {
|
||||
return password
|
||||
}
|
||||
|
||||
func readBase64OrNil(envKey string) (valueOrNil *string, err error) {
|
||||
value := getCleanedEnv(envKey)
|
||||
if value == "" {
|
||||
return nil, nil //nolint:nilnil
|
||||
}
|
||||
|
||||
decoded, err := decodeBase64(value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &decoded, nil
|
||||
}
|
||||
|
||||
func (r *Reader) readPIAEncryptionPreset() (presetPtr *string) {
|
||||
_, preset := r.getEnvWithRetro(
|
||||
"PRIVATE_INTERNET_ACCESS_OPENVPN_ENCRYPTION_PRESET",
|
||||
|
||||
Reference in New Issue
Block a user