SSL_GET_VERSION(3SSL)

πŸ“¦
version 4.0.3 Β· 2 versions
, in ubuntu stonking

✨ SSL_GET_VERSION ✨ (that's a section 3SSL OpenSSL page, bestie πŸ’–)

okay so real talk β€” this is the OpenSSL page about asking a connection what protocol are you even speaking rn πŸ¦‹ and there are like, a LOT of little functions that all do a slightly different flavour of that. let's get into it, no cap.


🌸 NAME 🌸

SSL_client_version, SSL_get_version, SSL_is_dtls, SSL_is_tls, SSL_is_quic, SSL_CTX_is_quic, SSL_CTX_is_server, SSL_version β€” get the protocol information of a connection πŸ‘‘ literally their whole job.


✨ SYNOPSIS ✨

like, the vibes, verbatim:

#include <openssl/ssl.h>

int SSL_client_version(const SSL *s);

const char *SSL_get_version(const SSL *ssl);

int SSL_is_dtls(const SSL *ssl);
int SSL_is_tls(const SSL *ssl);
int SSL_is_quic(const SSL *ssl);
int SSL_CTX_is_quic(const SSL_CTX *ctx);
int SSL_CTX_is_server(const SSL_CTX *ctx);

int SSL_version(const SSL *s);

πŸ’œ DESCRIPTION πŸ’œ

so for SSL, TLS and DTLS protocols β€” SSL_client_version() hands you the numeric protocol version that the client advertised in the legacy_version field of the ClientHello when it was initiating the connection. 🫢

⚠️ heads up bestie β€” for TLS, this value will never indicate a version greater than TLSv1.2, even if TLSv1.3 gets negotiated later. it's just built different (and by "different" i mean capped).

for QUIC connections tho? it returns OSSL_QUIC1_VERSION. slay.

SSL_get_version() returns the name of the protocol used for the connection. SSL_version() returns the numeric protocol version used for the connection. πŸŽ€

🚨 and listen β€” these two should only be called after the initial handshake has been completed. prior to that, the results returned from these functions may be unreliable. it's giving "don't ask yet, she's not ready" πŸ’…

SSL_is_dtls() returns 1 if the connection is using DTLS, or 0 if not.

SSL_is_tls() returns 1 if the connection is using SSL/TLS, or 0 if not.

SSL_is_quic() returns 1 if the connection is using QUIC, or 0 if not.

SSL_CTX_is_quic() returns 1 if the ctx creates QUIC SSL objects, or 0 if not.

SSL_CTX_is_server() returns 1 if the ctx uses a method that allows it to be a server (i.e. server-only or generic method), or 0 if not. main character energy fr fr πŸ‘‘


🌈 RETURN VALUES 🌈

SSL_get_version() returns one of these strings, and honestly each one is its own little era:

  • SSLv3 β€” the connection uses the SSLv3 protocol.
  • TLSv1 β€” the connection uses the TLSv1.0 protocol.
  • TLSv1.1 β€” the connection uses the TLSv1.1 protocol.
  • TLSv1.2 β€” the connection uses the TLSv1.2 protocol.
  • TLSv1.3 β€” the connection uses the TLSv1.3 protocol.
  • DTLSv0.9 β€” the connection uses an obsolete pre-standardisation DTLS protocol 😭
  • DTLSv1 β€” the connection uses the DTLSv1 protocol
  • DTLSv1.2 β€” the connection uses the DTLSv1.2 protocol
  • QUICv1 β€” the connection uses the QUICv1 protocol.
  • unknown β€” this indicates an unknown protocol version. πŸ™ˆ

and SSL_version() and SSL_client_version() return an integer which could include any of the following:

  • SSL3_VERSION β€” the connection uses the SSLv3 protocol.
  • TLS1_VERSION β€” the connection uses the TLSv1.0 protocol.
  • TLS1_1_VERSION β€” the connection uses the TLSv1.1 protocol.
  • TLS1_2_VERSION β€” the connection uses the TLSv1.2 protocol.
  • TLS1_3_VERSION β€” the connection uses the TLSv1.3 protocol (never returned for SSL_client_version()).
  • DTLS1_BAD_VER β€” the connection uses an obsolete pre-standardisation DTLS protocol 😭
  • DTLS1_VERSION β€” the connection uses the DTLSv1 protocol
  • DTLS1_2_VERSION β€” the connection uses the DTLSv1.2 protocol
  • OSSL_QUIC1_VERSION β€” the connection uses the QUICv1 protocol.

πŸ¦‹ SEE ALSO πŸ¦‹


πŸŽ€ HISTORY πŸŽ€

okay, storytime, who showed up when:

  • The SSL_is_dtls() function was added in OpenSSL 1.1.0.
  • The SSL_is_tls() and SSL_is_quic() functions were added in OpenSSL 3.2.

and then the glow-up continued:

  • The SSL_CTX_is_quic() and SSL_CTX_is_server() functions were added in OpenSSL 4.0

Copyright 2001-2026 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 🧚✨ mwah. this was OpenSSL 4.0.3, dated 2026-09-29, and it's SSL_GET_VERSION(3SSL) β€” periodt πŸ’…πŸ’œ

πŸ“¦ where this page comes from