How to Force Wget to Use TLSv1.2?

When downloading files via wget, you may occasionally need to explicitly specify the secure protocol version to overcome server compatibility issues, enforce strict security policies, or bypass outdated SSL configurations. By default, wget automatically negotiates the highest mutually supported protocol with the server. However, you can override this behavior entirely by utilizing the --secure-protocol flag followed by the specific protocol identifier, such as TLSv1_2. This article provides a straightforward guide on how to implement this command-line option, troubleshoot common TLS negotiation errors, and ensure secure file transfers.

Forcing TLSv1.2 with the Secure Protocol Flag

To force wget to establish a connection using strictly TLSv1.2, you must append the --secure-protocol option to your command. It is important to note that the protocol name uses an underscore (_) rather than a period (.) when passed as an argument.

Use the following command structure:

wget --secure-protocol=TLSv1_2 https://example.com/file.zip

Alternatively, you can use the shorter alias --https-only alongside the protocol configuration if you want to ensure no fallback to HTTP occurs, though --secure-protocol=TLSv1_2 inherently restricts the handshake to HTTPS.

Available Protocol Options

Depending on your version of wget and the underlying SSL/TLS library (OpenSSL or GnuTLS) compiled with it, the --secure-protocol flag accepts several specific arguments:

Argument Description
auto The default behavior; automatically negotiates a mutually supported protocol.
TLSv1_1 Forces the use of TLS version 1.1.
TLSv1_2 Forces the use of TLS version 1.2.
TLSv1_3 Forces the use of TLS version 1.3 (requires a modern wget build and OpenSSL 1.1.1+).
PFS Enforces Perfect Forward Secrecy cipher suites.

Troubleshooting Common Connection Issues

If your command fails after explicitly forcing TLSv1.2, the issue typically stems from one of three factors:

wget --secure-protocol=TLSv1_2 --no-check-certificate https://example.com/file.zip