SSL_GET_CURRENT_CIPHER(3SSL)
๐ SSL_GET_CURRENT_CIPHER โ ok bestie, let's talk ciphers ๐
So this is a page from the OpenSSL manual, section 3SSL, and it's literally all about grabbing the SSL_CIPHER of a connection. Yes queen, the whole squad of getter functions.
โจ NAME โจ
SSL_get_current_cipher, SSL_get_cipher_name, SSL_get_cipher, SSL_get_cipher_bits, SSL_get_cipher_version, SSL_get_pending_cipher โ get the SSL_CIPHER of a connection ๐
๐ธ SYNOPSIS ๐ธ
#include <openssl/ssl.h>
const SSL_CIPHER *SSL_get_current_cipher(const SSL *ssl);
const SSL_CIPHER *SSL_get_pending_cipher(const SSL *ssl);
const char *SSL_get_cipher_name(const SSL *s);
const char *SSL_get_cipher(const SSL *s);
int SSL_get_cipher_bits(const SSL *s, int *np);
const char *SSL_get_cipher_version(const SSL *s);
like. look at them. so many little functions. all of them just wanna tell you about ciphers ๐ฆ
๐ DESCRIPTION ๐
SSL_get_current_cipher() ๐
Returns a pointer to an SSL_CIPHER object, and that object holds the description of the cipher actually being used on a connection that was established with the ssl object.
โ ๏ธ<red>sslMUST NOT be NULL.` No cap. Do not do that.
If you want more deets on that object, go read SSL_CIPHER_get_name(3). iykyk ๐
SSL_get_cipher_name() and friends ๐ง
SSL_get_cipher_name()gets you the name of the cipher currently in use.SSL_get_cipher()is identical toSSL_get_cipher_name(). literally the same girl. twin behaviour.SSL_get_cipher_bits()is a macro that gets you the number of secret/algorithm bits used.SSL_get_cipher_version()returns the protocol name.
SSL_get_pending_cipher() ๐ฎ
Returns a pointer to an SSL_CIPHER object containing the description of the cipher (if any!) that has been negotiated for future use on the connection established with the ssl object โ but is not yet in use. she's booked but not on stage yet, periodt.
When does that even happen? It can happen during handshake processing, when control flow can be returned to the application through any of several callback methods. ๐
And now the caveat, bestie, pay attention:
The internal sequencing of handshake processing and callback invocation is not guaranteed to be stable from release to release. At present, only the callback set bySSL_CTX_set_alpn_select_cb()is guaranteed to have a non-NULLreturn value. Other callbacks may be added to this list over time. ๐
๐ซถ RETURN VALUES ๐ซถ
SSL_get_current_cipher()โ returns the cipher actually used, orNULLif no session has been established. ๐ญSSL_get_pending_cipher()โ returns the cipher to be used at the next change of cipher suite, orNULLif no such cipher is known.
โญ NOTES โญ
Okay so important vibe check: SSL_get_cipher, SSL_get_cipher_bits, SSL_get_cipher_version, and SSL_get_cipher_name are all implemented as macros. โจ Not real functions. Macros. The way that they're just macros is so iconic honestly.
๐ SEE ALSO ๐
๐ COPYRIGHT ๐
Copyright 2000-2018 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>.
k bye bestie, go read your ciphers ๐โจ๐๐ฆ๐ธ๐ ๐ซถ
this was OpenSSL 4.0.3, dated 2026-09-29 โ SSL_GET_CURRENT_CIPHER(3SSL), slay ๐
๐ฆ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms