SSL_GET_CURRENT_CIPHER(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… SSL_GET_CURRENT_CIPHER(3ossl) πŸ’…

okay so bestie, this is one of those 3ossl manual pages β€” OpenSSL's very own corner of the docs β€” and today we're talking about the little family of functions that tell you which cipher a connection is actually using. Think of it as the vibe check for your TLS session. πŸŽ€


✨ 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. that's the whole assignment, no cap. πŸ’–


🌸 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);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first up, SSL_get_current_cipher() β€” it returns a pointer to an SSL_CIPHER object, and that object is basically the little description card for the cipher actually being used on a connection that's been established with the ssl object. and bestie, listen: ssl MUST NOT be NULL. like, that's non-negotiable, do not pass NULL, we do not do that here πŸ™ˆ. for the deets, go peek at SSL_CIPHER_get_name(3).

SSL_get_cipher_name() β€” grabs the name of the cipher that's currently in use. iconic. 🌟

SSL_get_cipher() β€” literally identical to SSL_get_cipher_name(). same energy, different name, iykyk. πŸ’…

SSL_get_cipher_bits() β€” this one's a macro, and it hands you the number of secret/algorithm bits used. numbers, we love her. πŸ”₯

SSL_get_cipher_version() β€” returns the protocol name. that's it, that's the whole job. ✨

now, SSL_get_pending_cipher() is the main character of this section ngl β€” it returns a pointer to an SSL_CIPHER object containing the description of the cipher (if there even is one) that's been negotiated for future use on the connection established with the ssl object, but which is not yet in use. so like, it's the cipher waiting in the wings, sipping its drink, not on stage yet. πŸ“

when does that happen? it may be the case during handshake processing, when control flow can be returned to the application via any of several callback methods. and here's the caveat, so pay attention: the internal sequencing of handshake processing and callback invocation is not guaranteed to be stable from release to release. so don't go building your whole personality on it, fr fr. and 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 ⭐

SSL_get_cipher, SSL_get_cipher_bits, SSL_get_cipher_version, and SSL_get_cipher_name are implemented as macros. yes, all four. macros. don't be weird about it. πŸ’œ


🌈 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>.


🫢 and that's the whole page bestie β€” version 3.5.6, dated 2026-04-07, manual section SSL_GET_CURRENT_CIPHER(3ossl). go forth and check your ciphers, you gorgeous nerd. πŸ’…βœ¨πŸ§š
πŸ“¦ where this page comes from