SSL_GET_CIPHERS(3ossl)

✨ SSL_GET_CIPHERS β€” bestie's guide to the OpenSSL cipher-list girlies ✨

okay so. this is the SSL_get_ciphers(3ossl) page, and it's literally your one-stop shop for pulling lists of SSL_CIPHERs out of an SSL or SSL_CTX. no cap, every single flag is here, so grab a πŸ“ and let's go.


🌸 SYNOPSIS 🌸

#include <openssl/ssl.h>

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 *s);
STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *ssl);
int SSL_bytes_to_cipher_list(SSL *s, const unsigned char *bytes, size_t len,
                             int isv2format, STACK_OF(SSL_CIPHER) **sk,
                             STACK_OF(SSL_CIPHER) **scsvs);
const char *SSL_get_cipher_list(const SSL *ssl, int priority);
char *SSL_get_shared_ciphers(const SSL *s, char *buf, int size);

πŸ’… DESCRIPTION πŸ’…

SSL_get_ciphers() hands you the stack of available SSL_CIPHERs for ssl, all sorted by preference (aka the it-girl order πŸ’–). if ssl is NULL, or honestly if there are just no ciphers available, you get NULL back. so real.

SSL_CTX_get_ciphers() β€” same vibe, different girl: it returns the stack of available SSL_CIPHERs for ctx.

SSL_get1_supported_ciphers() returns the stack of enabled SSL_CIPHERs for ssl exactly as they'd be sent in a ClientHello (so yeah, sorted by preference ✨). and the way this list is built depends on so many settings: the cipher list, the supported protocol versions, the security level, and the enabled signature algorithms. SRP and PSK ciphers are only enabled if the appropriate callbacks or settings have been applied β€” no callbacks, no ciphers, periodt.

🚨 bestie heads up: the list of ciphers that would go out in a ClientHello can totally differ from the list of ciphers that would be acceptable when you're 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. if ssl is NULL or no ciphers are available, NULL is returned.

SSL_get_client_ciphers() returns the stack of available SSL_CIPHERs matching the list that was received from the client on ssl. if ssl is NULL, or no ciphers are available, or ssl is not operating in server mode β€” NULL. πŸ™ˆ

SSL_bytes_to_cipher_list() treats the supplied len octets in bytes as a wire-protocol cipher suite specification and parses the cipher suites supported by the library into the returned stacks of SSL_CIPHER objects sk and Signalling Cipher-Suite Values scsvs. it's in the three-octet-per-cipher SSLv2 wire format if isv2format is nonzero; otherwise it's the two-octet SSLv3/TLS wire format. unsupported cipher suites are just ignored (they didn't make the cut, sorry babe πŸ’€). returns 1 on success and 0 on failure.

SSL_get_cipher_list() returns a pointer to the name of the SSL_CIPHER listed for ssl with priority. if ssl is NULL, no ciphers are available, or there are less ciphers than priority available, you get NULL.

SSL_get_shared_ciphers() creates a colon separated and NUL terminated list of SSL_CIPHER names that are available in both the client and the server. buf is the buffer that should be populated with the list of names, and size is the size of that buffer. a pointer to buf is returned on success, or NULL on error. if the supplied buffer is not large enough to contain the complete list of names, then a truncated list of names will be returned (sad but it is what it is 😭).

⚠️ note that just because a ciphersuite is available (i.e. it is configured in the cipher list) and shared by both the client and the server, it does not mean that it is enabled β€” see the description of SSL_get1_supported_ciphers() above. this function will return available shared ciphersuites whether or not they are enabled.
πŸŽ€ also: this is a server side function only and must only be called after the completion of the initial handshake. the function sets an empty string when ssl fails the handshake due to the absence of shared ciphers.

πŸ¦‹ NOTES πŸ¦‹

the details of the ciphers obtained by 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. iykyk πŸ’œ

call SSL_get_cipher_list() with priority starting from 0 to obtain the sorted list of available ciphers, until NULL is returned.

πŸ’€ Note: SSL_get_ciphers(), SSL_CTX_get_ciphers() and SSL_get_client_ciphers() return a pointer to an internal cipher stack, which will be freed later on when the SSL or SSL_SESSION object is freed. therefore, the calling code MUST NOT free the return value itself. do not do it. not even once. 🫢

the stack returned by SSL_get1_supported_ciphers() should be freed using sk_SSL_CIPHER_free().

the stacks returned by SSL_bytes_to_cipher_list() should be freed using sk_SSL_CIPHER_free().


🌈 RETURN VALUES 🌈

see DESCRIPTION β€” yes queen, it's all up there ⭐


πŸ”₯ SEE ALSO πŸ”₯


Copyright 2000-2026 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 page, bestie!! this was OpenSSL 3.5.9, dated 2026-09-29, and it ate, no crumbs. go forth and slay those cipher lists πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from