Do you have a legacy application that doesn't support changing TLS settings at all? There are some evil #OpenSSL hacks to override it.
Inspect openssl.cnf
Open the file /etc/ssl/openssl.cfg, pay attention to the following line:
# Use this in order to automatically load providers.
openssl_conf = openssl_init
If this line exists, locate the [openssl_init] section below:
[openssl_init]
providers = provider_sect
This is the correct place to inject additional TLS configuration
for an override.
Ensure No Pre-existing ssl_conf Exists
Before injecting any custom configuration, it's important to ensure no
pre-existing ssl_conf configuration exists under openssl_init.
For example, on Fedora, the system already overrides OpenSSL's default to
enforce Red Hat's cryptography policy.
ssl_conf = ssl_module
[ ssl_module ]
system_default = crypto_policy
[ crypto_policy ]
.include = /etc/crypto-policies/back-ends/opensslcnf.config
In this case, it's not recommended to make any change to openssl.cnf,
one should consult the documentation of the existing system to understand
how the cryptography policy is managed. For example, on Fedora,
/etc/crypto-policies/back-ends/opensslcnf.config is an auto-generated
file, which should not be manually changed. Review the documentation below:
man crypto-policies
man update-crypto-policies
If one still wants to override the system, at the very least, one should
review any settings and files from the system's own customization first,
before commenting out the system's ssl_conf. For example, after injecting
my own /etc/ssl/ciphers.cnf, I'd include most existing settings from
/etc/crypto-policies/back-ends/opensslcnf.config.
Load default TLS policy configuration
If no pre-existing ssl_conf exists, or if the pre-existing ssl_conf
has been commented out, we can inject our own ssl_conf under
[openssl_init].
To minimize the change to openssl.cnf, it's recommended to inject an
include directive here:
[openssl_init]
providers = provider_sect
.include "/etc/ssl/ciphers.cnf"
Then, one can define the customization under /etc/ssl/ciphers.cnf:
ssl_conf = ssl_configuration
[ssl_configuration]
system_default = tls_system_default
[tls_system_default]
# Key = Value
It's also possible to customize the TLS client default and TLS
server default separately:
[ssl_configuration]
server = tls_server_default
client = tls_client_default
system_default = tls_system_default
[tls_server_default]
# Key = Value
[tls_client_default]
# Key = Value
[tls_system_default]
# Key = Value
Examples
- Use only PQC, X25519, and P-256 key exchanges
ssl_conf = ssl_configuration
[ssl_configuration]
system_default = tls_system_default
[tls_system_default]
Groups = X25519MLKEM768:X25519:prime256v1;
- Prioritize ChaCha20-Poly1305 above AES-GCM
ssl_conf = ssl_configuration
[ssl_configuration]
system_default = tls_system_default
[tls_system_default]
# Ciphersuits for TLSv1.3
Ciphersuites = TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256
# Ciphersuits for TLSv1.2 and below
CipherString = ECDHE+CHACHA20:ECDHE+AESGCM
# Preview the list via:
#
# openssl ciphers
# -ciphersuites 'TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256' \
# -v \
# 'ECDHE+CHACHA20:ECDHE+AESGCM'
- Only allow TLSv1.3
ssl_conf = ssl_configuration
[ssl_configuration]
system_default = tls_system_default
[tls_system_default]
TLS.MinProtocol = TLSv1.3
TLS.MaxProtocol = TLSv1.3
DTLS.MinProtocol = DTLSv1.3
DTLS.MaxProtocol = DTLSv1.3
- Only allow TLSv1.3 for outgoing connections
ssl_conf = ssl_configuration
[ssl_configuration]
client = tls_client_default
[tls_client_default]
TLS.MinProtocol = TLSv1.3
TLS.MaxProtocol = TLSv1.3
DTLS.MinProtocol = DTLSv1.3
DTLS.MaxProtocol = DTLSv1.3
Disclamer
It only works if the application uses the default untouched, if it actively changes the crypto settings, like OpenSMTPD, it won't work.
All of these settings above are untested. Test before use, run openssl ciphers first to see if openssl.cnf is corrupted or not, if the command still runs, at least the syntax is valid. If it doesn't, don't log out, fix it immediately since OpenSSL is now completely broken for the entire system! If the syntax checks out, next, you need to check the negotiated ciphersuits.