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>ssl MUST 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 to SSL_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 by SSL_CTX_set_alpn_select_cb() is guaranteed to have a non-NULL return value. Other callbacks may be added to this list over time. ๐Ÿ™ˆ

๐Ÿซถ RETURN VALUES ๐Ÿซถ

  • SSL_get_current_cipher() โ€” returns the cipher actually used, or NULL if no session has been established. ๐Ÿ˜ญ
  • SSL_get_pending_cipher() โ€” returns the cipher to be used at the next change of cipher suite, or NULL if 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 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