0

Is it possible to configure curl and/or wget to reject a DH key-exchange of less than or equal to 1024 bits. As a functional test, using curl/wget on https://dh1024.badssl.com/ should fail.

I was unable to find an answer to this question in the respective manpages and many Google searches.

Thanks in advance.

2
  • The sever configuration determines if an TLS connection is rejected. Curl or wget would just implement a specific TLS library to achieve the connection. – Ramhound Sep 9 '20 at 21:21
  • @Ramhound: that's at most half true. Both TLS client and server can abort the handshake, and either may do so based on code, config, options, user input, or anything else it likes including phase of the moon. – dave_thompson_085 Sep 10 '20 at 7:13
0

IME wget usually is built with OpenSSL (even though GnuTLS is more FSFish) and OpenSSL 1.1.0 up added a library-wide 'security level' that can be set using the API intended for ciphersuites. First 1.1.x release was 2016 so not all systems are now using it, although many are. E.g. on my Ubuntu 18.04:

$ openssl version; wget https://dh1024.badssl.com/
OpenSSL 1.1.1  11 Sep 2018
--(timestamp)--  https://dh1024.badssl.com/
Resolving dh1024.badssl.com (dh1024.badssl.com)... 104.154.89.105
Connecting to dh1024.badssl.com (dh1024.badssl.com)|104.154.89.105|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 573 [text/html]
Saving to: 'index.html'
...

but after editting /etc/ssl/openssl.cnf as described in https://stackoverflow.com/questions/62357205/openssl-cant-establish-ssl-connection-because-unsupported-protocol (and several others I didn't catch then) but with @SECLEVEL=2 (not 1) to prohibit DHE-1024:

$ wget  https://dh1024.badssl.com/
--(timestamp)--  https://dh1024.badssl.com/
Resolving dh1024.badssl.com (dh1024.badssl.com)... 104.154.89.105
Connecting to dh1024.badssl.com (dh1024.badssl.com)|104.154.89.105|:443... connected.
OpenSSL: error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small
Unable to establish SSL connection.

More recent versions of wget allow you do this directly on the commandline with --ciphers= but the one I have does not; check the manual for your version. (Or you could build a newer version yourself if you really want.)

curl supports many SSL/TLS implementations, and there is more variation in which is used. Ubuntu curl does use OpenSSL, and has the commandline option since forever, so:

$ curl -qI https://dh1024.badssl.com
HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Thu, 10 Sep 2020 07:08:14 GMT
Content-Type: text/html
Content-Length: 573
Last-Modified: Tue, 24 Mar 2020 00:15:54 GMT
Connection: keep-alive
ETag: "5e79513a-23d"
Cache-Control: no-store
Accept-Ranges: bytes

$ curl -qI --ciphers DEFAULT:@SECLEVEL=2 https://dh1024.badssl.com
curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small

Note that for other servers, the libraries used by wget and curl (not just OpenSSL but the others also) since about 2010 will normally offer both DHE and ECDHE ciphersuites, and most servers since maybe 2015 will support ECDHE and prefer it to DHE, so connecting to those won't use or check the DHE parameters. If you really want to check those servers you will probably need to specify cipher selection so as to induce the server to use DHE but without causing cipher selection to fail entirely. Also, recent wget and curl, in particular using OpenSSL 1.1.1 released 2018, will offer TLS 1.3; if the server also supports 1.3 then key exchange is very different: explicit FFDHE parameters are never used but instead, optionally, the standardized groups from RFC7919.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.