SSL_CTX_SET_CIPHER_LIST(3ossl)
π SSL_CTX_SET_CIPHER_LIST (3ossl) π
okay bestie, so this is one of those OpenSSL pages β you know, the OpenSSL manual family π
β and it's literally all about picking which ciphers are allowed. cipher shopping, if you will. let's get into it ποΈβ¨
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str);
int SSL_set_cipher_list(SSL *ssl, const char *str);
int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str);
int SSL_set_ciphersuites(SSL *s, const char *str);
const char *OSSL_default_cipher_list(void);
const char *OSSL_default_ciphersuites(void);
that's the whole squad π«Ά six functions, one mission.
π DESCRIPTION π
the TLSv1.2-and-below girlies
SSL_CTX_set_cipher_list()β sets the list of available ciphers (TLSv1.2 and below π°οΈ) forctx, using the control stringstr. the format of that string is described over inopenssl-ciphers(1)β go read it, it's giving lore. the cipher list is inherited by every singlesslobject created fromctx, so you set it once and all the babies get it. important though: this function does not touch TLSv1.3 ciphersuites β useSSL_CTX_set_ciphersuites()for those bestie. andctxMUST NOT beNULL, no cap, that's a hard rule. πSSL_set_cipher_list()β same energy, but sets the list of ciphers (TLSv1.2 and below) forsslonly. no inheritance, just that one object. lowkey the introvert of the group π
the TLSv1.3 ciphersuite girlies β¨
SSL_CTX_set_ciphersuites() is how you configure the available TLSv1.3 ciphersuites for ctx. it's a simple colon (":") separated list of TLSv1.3 ciphersuite names, listed in order of preference β first one is your main character π.
valid TLSv1.3 ciphersuite names are:
TLS_AES_128_GCM_SHA256TLS_AES_256_GCM_SHA384TLS_CHACHA20_POLY1305_SHA256TLS_AES_128_CCM_SHA256TLS_AES_128_CCM_8_SHA256TLS_SHA384_SHA384β integrity-only π«ΆTLS_SHA256_SHA256β integrity-only π«Ά
an empty list is permissible (yes, for real, that's allowed π« ). the default value for this setting is:
"TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256"
SSL_set_ciphersuites() is literally the same as SSL_CTX_set_ciphersuites() except it configures the ciphersuites for ssl instead of ctx. twins π
the default-havers π
OSSL_default_cipher_list()β returns the default cipher string for TLSv1.2 (and earlier) ciphers.OSSL_default_ciphersuites()β returns the default cipher string for TLSv1.3 ciphersuites.
π¦ NOTES π¦
okay so the control string str for SSL_CTX_set_cipher_list(), SSL_set_cipher_list(), SSL_CTX_set_ciphersuites() and SSL_set_ciphersuites() should be universally usable and should not depend on details of the library configuration (like which ciphers are compiled in). because of that, no syntax checking takes place π β items that aren't recognized, whether because the corresponding ciphers aren't compiled in or because they're just mistyped, are simply ignored. failure is only flagged if no ciphers could be collected at all. so like... typos just get ghosted, not yelled at π«₯
also important, bestie: including a cipher in the list is a necessary condition for it being used. on the client side, inclusion is also sufficient β unless the security level excludes it. on the server side though, additional restrictions apply. π€
all ciphers have additional requirements, fr fr:
- ADH ciphers don't need a certificate β but DH-parameters must have been set.
- all other ciphers need a corresponding certificate and key. π
more detail, because we don't skip:
- an RSA cipher can only be chosen when an RSA certificate is available. RSA ciphers using DHE need a certificate and key and additional DH-parameters (see
SSL_CTX_set_tmp_dh_callback(3)). - a DSA cipher can only be chosen when a DSA certificate is available. DSA ciphers always use DH key exchange and therefore need DH-parameters (see
SSL_CTX_set_tmp_dh_callback(3)).
when these conditions aren't met for any cipher in the list β for example a client only supports export RSA ciphers with an asymmetric key length of 512 bits and the server is not configured to use temporary RSA keys β then the "no shared cipher" (SSL_R_NO_SHARED_CIPHER) error is generated and the handshake will fail. ππ literally the worst-case scenario, do not let this be you.
also: OSSL_default_cipher_list() and OSSL_default_ciphersuites() replace SSL_DEFAULT_CIPHER_LIST and TLS_DEFAULT_CIPHERSUITES, respectively. the cipher list defines are deprecated as of 3.0 β οΈ so like, retire them, they've served their time ποΈ
πΈ RETURN VALUES πΈ
SSL_CTX_set_cipher_list()andSSL_set_cipher_list()return1if any cipher could be selected, and0on complete failure. π / πSSL_CTX_set_ciphersuites()andSSL_set_ciphersuites()return1if the requested ciphersuite list was configured, and0otherwise.
π SEE ALSO π
ssl(7), SSL_get_ciphers(3), SSL_CTX_use_certificate(3), SSL_CTX_set_tmp_dh_callback(3), openssl-ciphers(1)
go read them, they're all linked in the group chat π¬
π HISTORY π
OSSL_default_cipher_list() and OSSL_default_ciphersites() are new in 3.0. β¨ (yes, that spelling is exactly how it's written here, i don't make the rules π)
β COPYRIGHT β
Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole thing bestie, you ate that π«Άπ
version 3.5.0, dated 2026-09-25, from the SSL_CTX_SET_CIPHER_LIST(3ossl) era β mwah, go configure some ciphers, icon π§ββοΈβ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms