SSL_SESSION_GET0_CIPHER(3SSL)
π SSL_SESSION_GET0_CIPHER π
okay bestie, so this is a page from the OpenSSL manual, section 3SSL β that's the "library functions" section for SSL/TLS stuff. We're talking about getting and setting the cipher that's attached to an SSL session. Cute little duo of functions. Let's get into it π
β¨ NAME β¨
SSL_SESSION_get0_cipher, SSL_SESSION_set_cipher β grab the SSL cipher linked to a session, or set it. two directions, one glow-up π
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
const SSL_CIPHER *SSL_SESSION_get0_cipher(const SSL_SESSION *s);
int SSL_SESSION_set_cipher(SSL_SESSION *s, const SSL_CIPHER *cipher);
π¦ DESCRIPTION π¦
SSL_SESSION_get0_cipher() pulls out the cipher that the connection was using back when the session got created. Literally retrieves it for you. And if it can't figure out which cipher it was? You get NULL, no cipher, nothing, empty. π
heads up bestie β the thing it hands you is a pointer to an object that lives inside s itself. so do not release it. not yours to free. hands off π«Ά
SSL_SESSION_set_cipher() is the other direction, the main character move: it lets you set the ciphersuite associated with the SSL_SESSION s to cipher. Like, what's it for? For example, you could use it to set up a session based PSK β check SSL_CTX_set_psk_use_session_callback(3) for the deets β¨
π« RETURN VALUES π«
SSL_SESSION_get0_cipher()β returns theSSL_CIPHERassociated with theSSL_SESSION, orNULLif it just cannot be determined. no cipher, no answer, sorry babes πSSL_SESSION_set_cipher()β returns1on success, or0if it failed. simple as that.
π SEE ALSO π
ssl(7)d2i_SSL_SESSION(3)SSL_SESSION_get_time(3)SSL_SESSION_get0_hostname(3)SSL_SESSION_free(3)SSL_CTX_set_psk_use_session_callback(3)
go read those too, they're all part of the same little friend group π
β HISTORY β
SSL_SESSION_get0_cipher()β made its debut in OpenSSL 1.1.0SSL_SESSION_set_cipher()β showed up a little later, in OpenSSL 1.1.1
glow-up timeline, honestly π
π COPYRIGHT π
Copyright 2016-2017 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>.
aaaaand that's the whole page, bestie π no cap, every flag, every return value, every see-also link β all accounted for. this iconic little manpage is from OpenSSL 4.0.3, dated 2026-09-29, and yes it lives in section 3SSL. slay, go forth and cipher responsibly πβ¨π¦
π¦ 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