How to configure allowed ciphers and TLS versions in Cockpit
Environment
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
Issue
cockpitsupports TLS v1.1 and v1.2 by default, how to restrict Cockpit to only support TLS v1.2?- How to add or remove allowed ciphers for TLS in
cockpit?
Resolution
Red Hat Enterprise Linux 7
- Create
/etc/systemd/system/cockpit.service.ddirectory:
# mkdir /etc/systemd/system/cockpit.service.d - Create a file
/etc/systemd/system/cockpit.service.d/ssl.confwith the following content:[Service] Environment=G_TLS_GNUTLS_PRIORITY=NORMAL:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1 - If ciphers also need to be modified, for example, if requirements are for 128-bit and higher ciphers, the
NORMALstring can be changed toSECURE128which will require 128-bit and greater ciphers only:# cat /etc/systemd/system/cockpit.service.d/ssl.conf [Service] Environment=G_TLS_GNUTLS_PRIORITY=SECURE128:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1Refer to SSL/TLS Usage and Priority strings for further information.
Note that SSL3.0 and TLS1.0 must also be disabled. Even though they are disabled by default in Red Hat Enterprise Linux 7, creating the above file without specifying them will enable them. - Save the file and continue with Common Steps below.
Red Hat Enterprise Linux 8
In Red Hat Enterprise Linux 8 the configuration is handled by the system-wide crypto policy and the G_TLS_GNUTLS_PRIORITY environment variable is not evaluated. The global crypto settings can be adjusted by using the update-crypto-policies command, see the Chapter 5 of Security Hardening for details.
If only the cockpit crypto settings needs to be adjusted, it can be excluded from the crypto policies.
cockpit uses the gnutls library as its SSL back-end, follow the next steps to create a cockpit specific gnutls configuration:
- Create the
gnutls.configfile in a directory accessible tocockpit, e.g./etc/cockpit/gnutls.config. The content should be in the form of agnutlsPriority String. The example below is theFUTUREcrypto policygnutlsconfiguration string in Red Hat Enterprise Linux 8 at the time of writing this article.SYSTEM=NONE:+MAC-ALL:-SHA1:-MD5:+GROUP-ALL:-GROUP-FFDHE2048:+SIGN-ALL:-SIGN-RSA-MD5:-SIGN-RSA-SHA1:-SIGN-DSA-SHA1:-SIGN-ECDSA-SHA1:-SIGN-RSA-SHA224:-SIGN-DSA-SHA224:-SIGN-ECDSA-SHA224:-SIGN-DSA-SHA256:-SIGN-DSA-SHA384:-SIGN-DSA-SHA512:+CIPHER-ALL:-AES-128-GCM:-AES-128-CCM:-CAMELLIA-256-GCM:-CAMELLIA-128-GCM:-AES-256-CBC:-AES-128-CBC:-CAMELLIA-256-CBC:-CAMELLIA-128-CBC:-3DES-CBC:-ARCFOUR-128:+ECDHE-RSA:+ECDHE-ECDSA:+DHE-RSA:+VERS-ALL:-VERS-DTLS0.9:-VERS-TLS1.1:-VERS-TLS1.0:-VERS-SSL3.0:-VERS-DTLS1.0:+COMP-NULL:%PROFILE_HIGHThe TLS versions and allowed ciphers can be adjusted in a similar way as for Red Hat Enterprise Linux 7.
Refer to SSL/TLS Usage and Priority strings for further information.
Note that SSL3.0 and TLS1.0 must also be disabled. Even though they are disabled by default in Red Hat Enterprise Linux 8, creating the above file without specifying them will enable them. - Create a
cockpit.servicesystemdunit file override by running:# systemctl edit cockpit.service - Add the following content, using the
GNUTLS_SYSTEM_PRIORITY_FILEenvironment variable to pointgnutlsto the file created in step 1.[Service] Environment=GNUTLS_SYSTEM_PRIORITY_FILE=/etc/cockpit/gnutls.config - Save the file and continue with Common Steps below.
Common Steps
- Reload
systemdand restartcockpitservice:
# systemctl daemon-reload
# systemctl restart cockpit
Diagnostic Steps
Prior to making the above changes, TLS v1.1 is enabled:
# echo test | openssl s_client -connect localhost:9090 -tls1_1 2>&1 | grep -e Protocol -e Cipher
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-SHA
Protocol : TLSv1.1
Cipher : ECDHE-RSA-AES256-SHA
After making these changes, test that TLS v1.1 is disabled (Cipher: 0000):
# echo test | openssl s_client -connect localhost:9090 -tls1_1 2>&1 | grep -e Protocol -e Cipher
New, (NONE), Cipher is (NONE)
Protocol : TLSv1.1
Cipher : 0000
Test that TLS v1.2 is still enabled:
# echo test | openssl s_client -connect localhost:9090 -tls1_2 2>&1 | grep -e Protocol -e Cipher
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Protocol : TLSv1.2
Cipher : ECDHE-RSA-AES256-GCM-SHA384