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:
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/openvpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/openvpn/extract"
|
||||
)
|
||||
|
||||
type OpenVPNProviderSettings struct {
|
||||
@@ -190,15 +189,11 @@ func OpenVPNConfig(provider OpenVPNProviderSettings,
|
||||
}
|
||||
|
||||
if *settings.ClientCrt != "" {
|
||||
certData, err := extract.PEM([]byte(*settings.ClientCrt))
|
||||
panicOnError(err, "cannot extract client crt")
|
||||
lines.addLines(WrapOpenvpnCert(certData))
|
||||
lines.addLines(WrapOpenvpnCert(*settings.ClientCrt))
|
||||
}
|
||||
|
||||
if *settings.ClientKey != "" {
|
||||
keyData, err := extract.PEM([]byte(*settings.ClientKey))
|
||||
panicOnError(err, "cannot extract client private key")
|
||||
lines.addLines(WrapOpenvpnKey(keyData))
|
||||
lines.addLines(WrapOpenvpnKey(*settings.ClientKey))
|
||||
}
|
||||
|
||||
lines.addLines(provider.ExtraLines)
|
||||
@@ -247,14 +242,6 @@ func defaultStringSlice(value, defaultValue []string) (
|
||||
return result
|
||||
}
|
||||
|
||||
func panicOnError(err error, context string) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
panicMessage := fmt.Sprintf("%s: %s", context, err)
|
||||
panic(panicMessage)
|
||||
}
|
||||
|
||||
func WrapOpenvpnCA(certificate string) (lines []string) {
|
||||
return []string{
|
||||
"<ca>",
|
||||
|
||||
Reference in New Issue
Block a user