Compare commits

...

1 Commits

Author SHA1 Message Date
Quentin McGaw
5f3301f3a3 Use Openvpn 2.4 only 2024-11-08 16:41:37 +00:00
13 changed files with 27 additions and 49 deletions

View File

@@ -85,7 +85,7 @@ ENV VPN_SERVICE_PROVIDER=pia \
OPENVPN_PASSWORD= \ OPENVPN_PASSWORD= \
OPENVPN_USER_SECRETFILE=/run/secrets/openvpn_user \ OPENVPN_USER_SECRETFILE=/run/secrets/openvpn_user \
OPENVPN_PASSWORD_SECRETFILE=/run/secrets/openvpn_password \ OPENVPN_PASSWORD_SECRETFILE=/run/secrets/openvpn_password \
OPENVPN_VERSION=2.6 \ OPENVPN_VERSION=2.4 \
OPENVPN_VERBOSITY=1 \ OPENVPN_VERBOSITY=1 \
OPENVPN_FLAGS= \ OPENVPN_FLAGS= \
OPENVPN_CIPHERS= \ OPENVPN_CIPHERS= \
@@ -224,6 +224,9 @@ EXPOSE 8000/tcp 8888/tcp 8388/tcp 8388/udp
HEALTHCHECK --interval=5s --timeout=5s --start-period=10s --retries=3 CMD /gluetun-entrypoint healthcheck HEALTHCHECK --interval=5s --timeout=5s --start-period=10s --retries=3 CMD /gluetun-entrypoint healthcheck
ARG TARGETPLATFORM ARG TARGETPLATFORM
RUN apk add --no-cache --update -l wget && \ RUN apk add --no-cache --update -l wget && \
apk add --no-cache --update -X "https://dl-cdn.alpinelinux.org/alpine/v3.12/main" openvpn\~2.4 && \
apk add --no-cache --update -X "https://dl-cdn.alpinelinux.org/alpine/v3.16/main" openssl\~1.1 && \
mv /usr/sbin/openvpn /usr/sbin/openvpn2.4 && \
apk add --no-cache --update -X "https://dl-cdn.alpinelinux.org/alpine/v3.17/main" openvpn\~2.5 && \ apk add --no-cache --update -X "https://dl-cdn.alpinelinux.org/alpine/v3.17/main" openvpn\~2.5 && \
mv /usr/sbin/openvpn /usr/sbin/openvpn2.5 && \ mv /usr/sbin/openvpn /usr/sbin/openvpn2.5 && \
apk del openvpn && \ apk del openvpn && \

View File

@@ -270,6 +270,7 @@ func _main(ctx context.Context, buildInfo models.BuildInformation,
err = printVersions(ctx, logger, []printVersionElement{ err = printVersions(ctx, logger, []printVersionElement{
{name: "Alpine", getVersion: alpineConf.Version}, {name: "Alpine", getVersion: alpineConf.Version},
{name: "OpenVPN 2.4", getVersion: ovpnConf.Version24},
{name: "OpenVPN 2.5", getVersion: ovpnConf.Version25}, {name: "OpenVPN 2.5", getVersion: ovpnConf.Version25},
{name: "OpenVPN 2.6", getVersion: ovpnConf.Version26}, {name: "OpenVPN 2.6", getVersion: ovpnConf.Version26},
{name: "IPtables", getVersion: firewallConf.Version}, {name: "IPtables", getVersion: firewallConf.Version},

View File

@@ -19,7 +19,7 @@ import (
// OpenVPN contains settings to configure the OpenVPN client. // OpenVPN contains settings to configure the OpenVPN client.
type OpenVPN struct { type OpenVPN struct {
// Version is the OpenVPN version to run. // Version is the OpenVPN version to run.
// It can only be "2.5" or "2.6". // It can only be "2.4".
Version string `json:"version"` Version string `json:"version"`
// User is the OpenVPN authentication username. // User is the OpenVPN authentication username.
// It cannot be nil in the internal state if OpenVPN is used. // It cannot be nil in the internal state if OpenVPN is used.
@@ -90,7 +90,7 @@ var ivpnAccountID = regexp.MustCompile(`^(i|ivpn)\-[a-zA-Z0-9]{4}\-[a-zA-Z0-9]{4
func (o OpenVPN) validate(vpnProvider string) (err error) { func (o OpenVPN) validate(vpnProvider string) (err error) {
// Validate version // Validate version
validVersions := []string{openvpn.Openvpn25, openvpn.Openvpn26} validVersions := []string{openvpn.Openvpn24}
if err = validate.IsOneOf(o.Version, validVersions...); err != nil { if err = validate.IsOneOf(o.Version, validVersions...); err != nil {
return fmt.Errorf("%w: %w", ErrOpenVPNVersionIsNotValid, err) return fmt.Errorf("%w: %w", ErrOpenVPNVersionIsNotValid, err)
} }
@@ -289,7 +289,7 @@ func (o *OpenVPN) overrideWith(other OpenVPN) {
} }
func (o *OpenVPN) setDefaults(vpnProvider string) { func (o *OpenVPN) setDefaults(vpnProvider string) {
o.Version = gosettings.DefaultComparable(o.Version, openvpn.Openvpn26) o.Version = gosettings.DefaultComparable(o.Version, openvpn.Openvpn24)
o.User = gosettings.DefaultPointer(o.User, "") o.User = gosettings.DefaultPointer(o.User, "")
if vpnProvider == providers.Mullvad { if vpnProvider == providers.Mullvad {
o.Password = gosettings.DefaultPointer(o.Password, "m") o.Password = gosettings.DefaultPointer(o.Password, "m")

View File

@@ -4,9 +4,7 @@ import (
"fmt" "fmt"
"net/netip" "net/netip"
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
"github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/constants/vpn"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/pprof" "github.com/qdm12/gluetun/internal/pprof"
"github.com/qdm12/gosettings/reader" "github.com/qdm12/gosettings/reader"
@@ -162,18 +160,6 @@ func (s Settings) Warnings() (warnings []string) {
" so this will likely not work anymore. See https://github.com/qdm12/gluetun/issues/1498.") " so this will likely not work anymore. See https://github.com/qdm12/gluetun/issues/1498.")
} }
if helpers.IsOneOf(s.VPN.Provider.Name, providers.SlickVPN) &&
s.VPN.Type == vpn.OpenVPN {
warnings = append(warnings, "OpenVPN 2.5 and 2.6 use OpenSSL 3 "+
"which prohibits the usage of weak security in today's standards. "+
s.VPN.Provider.Name+" uses weak security which is out "+
"of Gluetun's control so the only workaround is to allow such weaknesses "+
`using the OpenVPN option tls-cipher "DEFAULT:@SECLEVEL=0". `+
"You might want to reach to your provider so they upgrade their certificates. "+
"Once this is done, you will have to let the Gluetun maintainers know "+
"by creating an issue, attaching the new certificate and we will update Gluetun.")
}
// TODO remove in v4 // TODO remove in v4
if s.DNS.ServerAddress.Unmap().Compare(netip.AddrFrom4([4]byte{127, 0, 0, 1})) != 0 { if s.DNS.ServerAddress.Unmap().Compare(netip.AddrFrom4([4]byte{127, 0, 0, 1})) != 0 {
warnings = append(warnings, "DNS address is set to "+s.DNS.ServerAddress.String()+ warnings = append(warnings, "DNS address is set to "+s.DNS.ServerAddress.String()+

View File

@@ -30,7 +30,7 @@ func Test_Settings_String(t *testing.T) {
| | ├── Protocol: UDP | | ├── Protocol: UDP
| | └── Private Internet Access encryption preset: strong | | └── Private Internet Access encryption preset: strong
| └── OpenVPN settings: | └── OpenVPN settings:
| ├── OpenVPN version: 2.6 | ├── OpenVPN version: 2.4
| ├── User: [not set] | ├── User: [not set]
| ├── Password: [not set] | ├── Password: [not set]
| ├── Private Internet Access encryption preset: strong | ├── Private Internet Access encryption preset: strong

View File

@@ -1,6 +1,5 @@
package openvpn package openvpn
const ( const (
Openvpn25 = "2.5" Openvpn24 = "2.4"
Openvpn26 = "2.6"
) )

View File

@@ -13,8 +13,7 @@ import (
var ErrVersionUnknown = errors.New("OpenVPN version is unknown") var ErrVersionUnknown = errors.New("OpenVPN version is unknown")
const ( const (
binOpenvpn25 = "openvpn2.5" binOpenvpn24 = "openvpn2.4"
binOpenvpn26 = "openvpn2.6"
) )
func start(ctx context.Context, starter CmdStarter, version string, flags []string) ( func start(ctx context.Context, starter CmdStarter, version string, flags []string) (
@@ -22,10 +21,8 @@ func start(ctx context.Context, starter CmdStarter, version string, flags []stri
) { ) {
var bin string var bin string
switch version { switch version {
case openvpn.Openvpn25: case openvpn.Openvpn24:
bin = binOpenvpn25 bin = binOpenvpn24
case openvpn.Openvpn26:
bin = binOpenvpn26
default: default:
return nil, nil, nil, fmt.Errorf("%w: %s", ErrVersionUnknown, version) return nil, nil, nil, fmt.Errorf("%w: %s", ErrVersionUnknown, version)
} }

View File

@@ -8,12 +8,8 @@ import (
"strings" "strings"
) )
func (c *Configurator) Version25(ctx context.Context) (version string, err error) { func (c *Configurator) Version24(ctx context.Context) (version string, err error) {
return c.version(ctx, binOpenvpn25) return c.version(ctx, binOpenvpn24)
}
func (c *Configurator) Version26(ctx context.Context) (version string, err error) {
return c.version(ctx, binOpenvpn26)
} }
var ErrVersionTooShort = errors.New("version output is too short") var ErrVersionTooShort = errors.New("version output is too short")

View File

@@ -28,6 +28,8 @@ func (p *Provider) OpenVPNConfig(connection models.Connection,
} }
switch settings.Version { switch settings.Version {
case openvpn.Openvpn24:
providerSettings.Ciphers = []string{openvpn.AES256cbc}
case openvpn.Openvpn25, openvpn.Openvpn26: case openvpn.Openvpn25, openvpn.Openvpn26:
providerSettings.Ciphers = []string{ providerSettings.Ciphers = []string{
openvpn.AES256gcm, openvpn.AES256cbc, openvpn.AES192gcm, openvpn.AES256gcm, openvpn.AES256cbc, openvpn.AES192gcm,

View File

@@ -64,8 +64,8 @@ func Test_modifyConfig(t *testing.T) {
"suppress-timestamps", "suppress-timestamps",
"auth-user-pass /etc/openvpn/auth.conf", "auth-user-pass /etc/openvpn/auth.conf",
"verb 0", "verb 0",
"data-ciphers-fallback cipher", "cipher cipher", //nolint:dupword
"data-ciphers cipher", "ncp-ciphers cipher",
"auth sha512", "auth sha512",
"mssfix 1000", "mssfix 1000",
"pull-filter ignore \"route-ipv6\"", "pull-filter ignore \"route-ipv6\"",

View File

@@ -31,11 +31,5 @@ func (p *Provider) OpenVPNConfig(connection models.Connection,
}, },
} }
// SlickVPN's certificate is sha1WithRSAEncryption and sha1 is now
// rejected by openssl 3.x.x which is used by OpenVPN >= 2.5.
// We lower the security level to 3 to allow this algorithm,
// see https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_security_level.html
providerSettings.TLSCipher = "DEFAULT:@SECLEVEL=0"
return utils.OpenVPNConfig(providerSettings, connection, settings, ipv6Supported) return utils.OpenVPNConfig(providerSettings, connection, settings, ipv6Supported)
} }

View File

@@ -10,7 +10,7 @@ func CipherLines(ciphers []string) (lines []string) {
} }
return []string{ return []string{
"data-ciphers-fallback " + ciphers[0], "cipher " + ciphers[0],
"data-ciphers " + strings.Join(ciphers, ":"), "ncp-ciphers " + strings.Join(ciphers, ":"),
} }
} }

View File

@@ -16,16 +16,16 @@ func Test_CipherLines(t *testing.T) {
"empty version": { "empty version": {
ciphers: []string{"AES"}, ciphers: []string{"AES"},
lines: []string{ lines: []string{
"data-ciphers-fallback AES", "cipher AES",
"data-ciphers AES", "ncp-ciphers AES",
}, },
}, },
"2.5": { "2.4": {
ciphers: []string{"AES", "CBC"}, ciphers: []string{"AES", "CBC"},
version: "2.5", version: "2.4",
lines: []string{ lines: []string{
"data-ciphers-fallback AES", "cipher AES",
"data-ciphers AES:CBC", "ncp-ciphers AES:CBC",
}, },
}, },
} }