SSL_GET_SHARED_CIPHERS(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

🌸 NAME 🌸

okay so bestie, welcome to SSL_GET_SHARED_CIPHERS(3) β€” yes, that's the page title, and it lives in the Library Functions Manual. It's literally about ciphers supported by both client and server. It's giving β€œcan we please agree on something” energy πŸ’….

✨ SYNOPSIS ✨

library β€œlibssl” libcrypto #include <openssl/ssl.h>

char *
SSL_get_shared_ciphers(const SSL *ssl, char *buf, int len);

πŸ¦‹ DESCRIPTION πŸ¦‹

So if ssl contains a session in server mode, SSL_get_shared_ciphers() puts as many names of ciphers that are supported by both the client and the server into the buffer buf as the buffer is long enough to contain. Names are separated by colons. At most len bytes are written to buf including the terminating NUL character.

Like, it's filling your cute little buf with the shared-cipher lineup, colon-separated, and it will not go past len bytes β€” NUL included, bestie 🌸.

πŸ’– RETURN VALUES πŸ’–

SSL_get_shared_ciphers() returns buf on success or NULL on failure. The following situations cause failure:

  • SSL_is_server(3) is false β€” i.e., ssl is not set to server mode.
  • SSL_get_ciphers(3) is NULL or empty β€” i.e., no ciphers are available for use by the server.
  • SSL_get_session(3) is NULL β€” i.e., ssl contains no session.
  • SSL_get_client_ciphers(3) is NULL or empty β€” i.e., ssl contains no information about ciphers supported by the client, or the client does not support any ciphers.
  • The len argument is less than 2 β€” tiny-buffer behavior, and yes, it causes failure.

🌈 SEE ALSO 🌈

Go read these too, bestie β€” they're in the group chat 🫢.

πŸŽ€ HISTORY πŸŽ€

SSL_get_shared_ciphers() first appeared in SSLeay 0.4.5b and has been available since OpenBSD 2.4. Old-school but still iconic ✨.

πŸ’€ BUGS πŸ’€

If the list is too long to fit into len bytes, it is silently truncated after the last cipher name that fits, and all following ciphers are skipped. If the buffer is very short such that even the first cipher name does not fit, an empty string is returned even when some shared ciphers are actually available.

There is no easy way to find out how much space is required for buf or whether the supplied space was sufficient.

bestie, this is the messy part: silent truncation and no easy way to check if your buf was big enough. Not me finding out the hard way 😭.

mwah πŸ’‹ this cutie came from Debian, dated June 8, 2025 β€” SSL_GET_SHARED_CIPHERS(3), out! 🫢✨

πŸ“¦ where this page comes from