SSL_GET_CIPHERS(3)
π
SSL_GET_CIPHERS β like, the whole girl-gang of SSL_CIPHERs
okay so this is a page from the Library Functions Manual, bestie, and it's all about getting your hands on lists of ciphers. plural. a whole stack of them. let's go π
πΈ NAME πΈ
SSL_get_ciphers, SSL_CTX_get_ciphers, SSL_get1_supported_ciphers, SSL_get_client_ciphers, SSL_get_cipher_list β get lists of available SSL_CIPHERs.
like, all five of these functions are out here handing you ciphers. five besties, one mission. iykyk π
β¨ SYNOPSIS β¨
first off, the library line, literally exactly as it appears:
library βlibsslβ libcrypto #include <openssl/ssl.h>
and then the functions themselves, no cap:
STACK_OF(SSL_CIPHER) *
SSL_get_ciphers(const SSL *ssl);
STACK_OF(SSL_CIPHER) *
SSL_CTX_get_ciphers(const SSL_CTX *ctx);
STACK_OF(SSL_CIPHER) *
SSL_get1_supported_ciphers(SSL *ssl);
STACK_OF(SSL_CIPHER) *
SSL_get_client_ciphers(const SSL *ssl);
const char *
SSL_get_cipher_list(const SSL *ssl, int priority);
π¦ DESCRIPTION π¦
okay so let's take these one at a time because each one has its own vibe π
SSL_get_ciphers()β returns the stack of availableSSL_CIPHERs for ssl, sorted by preference. the main character of the group, honestly.SSL_CTX_get_ciphers()β returns the stack of availableSSL_CIPHERs for ctx. same energy, different object. π«ΆSSL_get1_supported_ciphers()β returns a stack of enabledSSL_CIPHERs for ssl as it would be sent in a ClientHello, sorted by preference. and the list is lowkey a whole personality β it depends on settings like the cipher list, the supported protocol versions, the security level, and the enabled signature algorithms. also, the list of ciphers that would be sent in a ClientHello can differ from the list of ciphers that would be acceptable when acting as a server. for example, additional ciphers may be usable by a server if there's a gap in the list of supported protocols, and some ciphers may not be usable by a server if there isn't a suitable certificate configured. it's giving "context matters." πSSL_get_client_ciphers()β returns the stack of availableSSL_CIPHERs matching the list received from the client on ssl. π
the details of the ciphers you get from SSL_get_ciphers(), SSL_CTX_get_ciphers(), SSL_get1_supported_ciphers(), and SSL_get_client_ciphers() can be obtained using the SSL_CIPHER_get_name(3) family of functions. yes, the whole family. iconic π
SSL_get_cipher_list() β okay, tea time π΅ this one is deprecated (use SSL_get_ciphers() instead, bestie, please) and it's badly misnamed. like, the audacity. it does not return a list β it returns the name of one element of the return value of SSL_get_ciphers(), with the index given by the priority argument. passing 0 selects the cipher with the highest priority. to iterate over all available ciphers in decreasing priority, repeatedly increment the argument by 1 until NULL is returned. that's the whole loop. no, it's not a list, we've been over this π
π₯ RETURN VALUES π₯
listen up, because the lifetime rules here are the drama π
SSL_get_ciphers()returns an internal pointer to a list of ciphers, orNULLif ssl isNULLor if no ciphers are available. and here's the wild part β the returned pointer may not only become invalid when ssl is destroyed or whenSSL_set_cipher_list(3)is called on it, but also when theSSL_CTXobject in use by ssl at the time of the call is freed, or whenSSL_CTX_set_cipher_list(3)is called on that context object. not me getting expired by an object i never even touched πSSL_CTX_get_ciphers()returns an internal pointer to a list of ciphers, orNULLif ctx isNULLor if no ciphers are available. the returned pointer becomes invalid when ctx is destroyed or whenSSL_CTX_set_cipher_list(3)is called on it. simple, clean, predictable. we love her β¨SSL_get1_supported_ciphers()returns a newly allocated list of ciphers, orNULLif ssl isNULL, if no ciphers are available, or if an error occurs. when the returned pointer is no longer needed, the caller is responsible for freeing it usingsk_SSL_CIPHER_free(). yes that means you. don't leave her hanging, that's a memory leak πΈSSL_get_client_ciphers()returns an internal pointer to a list of ciphers, orNULLif ssl isNULL, has no active session, or is not operating in server mode. the returned pointer becomes invalid when theSSL_SESSIONobject is destroyed β even if thesslobject remains valid. and it may also become invalid in other circumstances, for example when processing a new ClientHello. so like... handle with care πSSL_get_cipher_list()returns an internal pointer to a string, orNULLif ssl isNULL, if no ciphers are available, or if priority is greater than or equal to the number of available ciphers. off the end of the array = nothing for you, bestie π
β SEE ALSO β
go read these too, fr fr:
π HISTORY π
storytime, bestie π
SSL_get_cipher_list()first appeared in SSLeay 0.5.2.SSL_get_ciphers()first appeared in SSLeay 0.8.0.- both functions have been available since OpenBSD 2.4. literal elders, we respect them π«‘
SSL_CTX_get_ciphers()first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 6.3.SSL_get1_supported_ciphers()andSSL_get_client_ciphers()first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 6.5.
aaand that's the page!! π this one's from Debian, dated June 8, 2025 β so if you're reading this in a group chat years from now, that's where she came from. mwah, go free your ciphers responsibly πππ¦
π¦ 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) 2020 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2000, 2005, 2015, 2016, 2017 The OpenSSL Project
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms