SSL_SESSION_...OCOL_VERSION(3ossl)

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

πŸ’… SSL_SESSION_get_protocol_version, SSL_SESSION_set_protocol_version β€” get and set the session protocol version πŸŽ€

okay bestie, welcome to the 3ossl corner of the manual, this one's short and sweet and honestly kinda iconic ✨


🌸 SYNOPSIS 🌸

like, include the header first obviously:

#include <openssl/ssl.h>

then the two function girlies:

int SSL_SESSION_get_protocol_version(const SSL_SESSION *s);
int SSL_SESSION_set_protocol_version(SSL_SESSION *s, int version);

πŸ¦‹ DESCRIPTION πŸ¦‹

so SSL_SESSION_get_protocol_version() returns the protocol version number that session s is using. that's it. that's the whole vibe check. πŸ’–

and SSL_SESSION_set_protocol_version() sets the protocol version associated with the SSL_SESSION object s to the value version. lowkey important detail: this value should be a version constant such as TLS1_3_VERSION etc. ✨ for example, this could be used to set up a session based PSK (peep SSL_CTX_set_psk_use_session_callback(3) if you wanna go deeper πŸ‘€).


πŸ’… RETURN VALUES πŸ’…

SSL_SESSION_get_protocol_version() returns a number indicating the protocol version used for the session; this number matches the constants e.g. TLS1_VERSION, TLS1_2_VERSION or TLS1_3_VERSION. so like, very on-brand, no surprises. πŸŽ€

⚠️ okay heads up bestie, SSL_SESSION_get_protocol_version() does not perform a null check on the provided session s pointer. so don't be handing it a null and then acting shocked, fr fr. πŸ’€

SSL_SESSION_set_protocol_version() returns 1 on success or 0 on failure. slay or flop, binary queen. πŸ‘‘


🌈 SEE ALSO 🌈


🧚 HISTORY 🧚

  • SSL_SESSION_get_protocol_version() was added in OpenSSL 1.1.0 ⭐
  • SSL_SESSION_set_protocol_version() was added in OpenSSL 1.1.1 🌸

Copyright 2001-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, no cap πŸ›πŸ’œ β€” brought to you by OpenSSL 3.5.6, dated 2026-04-07, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from