xref: /openssl/doc/man3/SSL_get_version.pod (revision da1c088f)
1=pod
2
3=head1 NAME
4
5SSL_client_version, SSL_get_version, SSL_is_dtls, SSL_is_tls, SSL_is_quic,
6SSL_version - get the protocol information of a connection
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 int SSL_client_version(const SSL *s);
13
14 const char *SSL_get_version(const SSL *ssl);
15
16 int SSL_is_dtls(const SSL *ssl);
17 int SSL_is_tls(const SSL *ssl);
18 int SSL_is_quic(const SSL *ssl);
19
20 int SSL_version(const SSL *s);
21
22=head1 DESCRIPTION
23
24For SSL, TLS and DTLS protocols SSL_client_version() returns the numeric
25protocol version advertised by the client in the legacy_version field of the
26ClientHello when initiating the connection. Note that, for TLS, this value
27will never indicate a version greater than TLSv1.2 even if TLSv1.3 is
28subsequently negotiated. For QUIC connections it returns OSSL_QUIC1_VERSION.
29
30SSL_get_version() returns the name of the protocol used for the connection.
31SSL_version() returns the numeric protocol version used for the connection.
32They should only be called after the initial handshake has been completed.
33Prior to that the results returned from these functions may be unreliable.
34
35SSL_is_dtls() returns 1 if the connection is using DTLS or 0 if not.
36
37SSL_is_tls() returns 1 if the connection is using SSL/TLS or 0 if not.
38
39SSL_is_quic() returns 1 if the connection is using QUIC or 0 if not.
40
41=head1 RETURN VALUES
42
43
44SSL_get_version() returns one of the following strings:
45
46=over 4
47
48=item SSLv3
49
50The connection uses the SSLv3 protocol.
51
52=item TLSv1
53
54The connection uses the TLSv1.0 protocol.
55
56=item TLSv1.1
57
58The connection uses the TLSv1.1 protocol.
59
60=item TLSv1.2
61
62The connection uses the TLSv1.2 protocol.
63
64=item TLSv1.3
65
66The connection uses the TLSv1.3 protocol.
67
68=item DTLSv0.9
69
70The connection uses an obsolete pre-standardisation DTLS protocol
71
72=item DTLSv1
73
74The connection uses the DTLSv1 protocol
75
76=item DTLSv1.2
77
78The connection uses the DTLSv1.2 protocol
79
80=item QUICv1
81
82The connection uses the QUICv1 protocol.
83
84=item unknown
85
86This indicates an unknown protocol version.
87
88=back
89
90SSL_version() and SSL_client_version() return an integer which could include any
91of the following:
92
93=over 4
94
95=item SSL3_VERSION
96
97The connection uses the SSLv3 protocol.
98
99=item TLS1_VERSION
100
101The connection uses the TLSv1.0 protocol.
102
103=item TLS1_1_VERSION
104
105The connection uses the TLSv1.1 protocol.
106
107=item TLS1_2_VERSION
108
109The connection uses the TLSv1.2 protocol.
110
111=item TLS1_3_VERSION
112
113The connection uses the TLSv1.3 protocol (never returned for
114SSL_client_version()).
115
116=item  DTLS1_BAD_VER
117
118The connection uses an obsolete pre-standardisation DTLS protocol
119
120=item DTLS1_VERSION
121
122The connection uses the DTLSv1 protocol
123
124=item DTLS1_2_VERSION
125
126The connection uses the DTLSv1.2 protocol
127
128=item OSSL_QUIC1_VERSION
129
130The connection uses the QUICv1 protocol.
131
132=back
133
134=head1 SEE ALSO
135
136L<ssl(7)>
137
138=head1 HISTORY
139
140The SSL_is_dtls() function was added in OpenSSL 1.1.0. The SSL_is_tls() and
141SSL_is_quic() functions were added in OpenSSL 3.2.
142
143=head1 COPYRIGHT
144
145Copyright 2001-2023 The OpenSSL Project Authors. All Rights Reserved.
146
147Licensed under the Apache License 2.0 (the "License").  You may not use
148this file except in compliance with the License.  You can obtain a copy
149in the file LICENSE in the source distribution or at
150L<https://www.openssl.org/source/license.html>.
151
152=cut
153