SSL_GET_CURRENT_CIPHER(3ossl)
π SSL_GET_CURRENT_CIPHER(3ossl) β the OpenSSL manual, but make it make sense
okay so bestie, this is the 3ossl page about figuring out which cipher is actually doing the work on your TLS connection. yes, ciphers. yes, the little cryptographic handshake outfits your connection is wearing. we're getting the SSL_CIPHER of a connection and honestly? iconic. π₯
β¨ NAME β¨
SSL_get_current_cipher, SSL_get_cipher_name, SSL_get_cipher, SSL_get_cipher_bits, SSL_get_cipher_version, SSL_get_pending_cipher β all of these are here to get the SSL_CIPHER of a connection. that's the whole vibe. π
πΈ 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, copy-paste it exactly, don't come for me. π
π¦ DESCRIPTION π¦
the main character: SSL_get_current_cipher()
SSL_get_current_cipher() hands you back a pointer to an SSL_CIPHER object β and that object is literally the description of the cipher actually being used on a connection that was established with the ssl object. no cap.
β οΈ <red>ssl MUST NOT be NULL.</red> like for real for real, don't do that. π
if you want more deets on the cipher object itself, go see SSL_CIPHER_get_name(3). iykyk.
the little helpers π§
SSL_get_cipher_name()β gets you the name of the cipher that's currently in use. slay.SSL_get_cipher()β literally identical toSSL_get_cipher_name(). twins. same energy. π―SSL_get_cipher_bits()β this one's a macro, and it gets you the number of secret/algorithm bits used. numbers, we love her.SSL_get_cipher_version()β returns the protocol name. cute.
the mysterious one: SSL_get_pending_cipher() π
SSL_get_pending_cipher() returns a pointer to an SSL_CIPHER object containing the description of the cipher (if any) that's been negotiated for future use on the connection established with the ssl object β but is not yet in use.
when does that even happen? during handshake processing, babes β specifically when control flow can be returned to the application via any of several callback methods. so you're mid-handshake, a callback fires, and you're like "wait what cipher are we gonna use π".
π big caveat time: the internal sequencing of handshake processing and callback invocation is not guaranteed to be stable from release to release. and 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. so likeβ¦ don't build your whole personality on it, yk? π«Ά
β RETURN VALUES β
SSL_get_current_cipher()β returns the cipher actually used, orNULLif no session has been established. (no session? no cipher. simple as that.)SSL_get_pending_cipher()β returns the cipher to be used at the next change of cipher suite, orNULLif no such cipher is known.
like, NULL is always a possibility bestie, check your returns. π
π NOTES π
heads up: SSL_get_cipher, SSL_get_cipher_bits, SSL_get_cipher_version, and SSL_get_cipher_name are implemented as macros. so like, they're not real functions, they're macros serving looks. π
π SEE ALSO π
go read those too, they're giving lore. πβ¨
π 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>.
and that's the tea π β this page is from OpenSSL 3.5.0, dated 2026-09-25, and it's SSL_GET_CURRENT_CIPHER(3ossl) in case you forgot where you were. go get that cipher, bestie, you're gonna ate. ππ¦β¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms