LIBRESSL-SSL_CTX_SET_SECURITY_LEVEL(3)
π SSL_CTX_set_security_level & friends: the TLS security-level glow-up
okay so this is the LIBRESSL-SSL_CTX_SET_SECURITY_LEVEL(3) page from the Library Functions Manual, and itβs literally all about changing the security level for TLS. Bestie, weβre in it π
πΈ NAME πΈ
SSL_CTX_set_security_level, SSL_set_security_level, SSL_CTX_get_security_level, SSL_get_security_level β change security level for TLS β¨
π SYNOPSIS π
ok so the synopsis is giving exactly this:
library βlibsslβ libcrypto
#include <openssl/ssl.h>
void
SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
void
SSL_set_security_level(SSL *s, int level);
int
SSL_CTX_get_security_level(const SSL_CTX *ctx);
int
SSL_get_security_level(const SSL *s);
π¦ DESCRIPTION π¦
A security level is a set of restrictions on algorithms, key lengths, protocol versions, and other features in TLS connections. These restrictions apply in addition to those that exist from individually selecting supported features, for example ciphers, curves, or algorithms. No cap, itβs an extra layer of βbestie, maybe donβtβ π
Hereβs the table of properties for the various security levels β exactly the vibe check:
# sec RSA ECC TLS MAC
0 0 0 0 1.0 MD5
1 80 1024 160 1.0 RC4
2 112 2048 224 1.0
3 128 3072 256 1.1 SHA1
4 192 7680 384 1.2
5 256 15360 512 1.2
The meaning of the columns is as follows:
#β the number of the level.secβ the minimum security strength measured in bits, which is approximately the binary logarithm of the number of operations an attacker has to perform in order to break a cryptographic key. This minimum strength is enforced for all relevant parameters including cipher suite encryption algorithms, ECC curves, signature algorithms, DH parameter sizes, and certificate algorithms and key sizes. SeeSP800-57below underSEE ALSOfor details on individual algorithms.RSAβ the minimum key length in bits for the RSA and DH algorithms.ECCβ the minimum key length in bits for ECC algorithms.TLSβ the minimum TLS protocol version.MACβ cipher suites using the given MACs are allowed on this level and on lower levels, but not on higher levels.
Level 0 is only provided for backward compatibility and permits everything. Itβs the βno rules, just vibesβ level, but make of that what you will π
Level 3 and higher disable support for session tickets and only accept cipher suites that provide forward secrecy. Slay for security, lowkey strict about it π₯
The functions SSL_CTX_set_security_level() and SSL_set_security_level() choose the security level for ctx or s, respectively. If not set, security level 1 is used.
SSL_CTX_new(3) initializes the security level of the new object to 1.
SSL_new(3) and SSL_set_SSL_CTX(3) copy the security level from the context to the SSL object.
SSL_dup(3) copies the security level from the old to the new object. Copy-paste but make it cryptographic π
β RETURN VALUES β
SSL_CTX_get_security_level() and SSL_get_security_level() return the security level configured in ctx or s, respectively. The getter girlies are just reporting the number, periodt π«Ά
π SEE ALSO π
Elaine Barker, Recommendation for Key Management, U.S. National Institute of Standards and Technology, NIST Special Publication 800-57 Part 1 Revision 5, https://doi.org/10.6028/NIST.SP.800-57pt1r5, Gaithersburg, MD, May 2020.
π§ HISTORY π§
These functions first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 7.2. iconic behavior, honestly β¨
π CAVEATS π
Applications which do not check the return values of configuration functions will misbehave. For example, if an application does not check the return value after trying to set a certificate and the certificate is rejected because of the security level, the application may behave as if no certificate had been provided at all. Not me forgetting the return value checkβ¦ couldnβt be me π
While some restrictions may be handled gracefully by negotiations between the client and the server, other restrictions may be fatal and abort the TLS handshake. For example, this can happen if the peer certificate contains a key that is too short or if the DH parameter size is too small. So yeah, sometimes itβs a whole dramatic handshake breakup π
mwah π this page is from Debian, dated June 8, 2025, and itβs the SSL_CTX_SET_SECURITY_LEVEL(3) manual page β bye bestie, go check those return values π«ΆπΈ
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms