1SSL_CTX_SET_CLIENT_HELLO_CB(3)      OpenSSL     SSL_CTX_SET_CLIENT_HELLO_CB(3)
2
3
4

NAME

6       SSL_CTX_set_client_hello_cb, SSL_client_hello_cb_fn,
7       SSL_client_hello_isv2, SSL_client_hello_get0_legacy_version,
8       SSL_client_hello_get0_random, SSL_client_hello_get0_session_id,
9       SSL_client_hello_get0_ciphers,
10       SSL_client_hello_get0_compression_methods,
11       SSL_client_hello_get1_extensions_present, SSL_client_hello_get0_ext -
12       callback functions for early server-side ClientHello processing
13

SYNOPSIS

15        typedef int (*SSL_client_hello_cb_fn)(SSL *s, int *al, void *arg);
16        void SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn *f,
17                                         void *arg);
18        int SSL_client_hello_isv2(SSL *s);
19        unsigned int SSL_client_hello_get0_legacy_version(SSL *s);
20        size_t SSL_client_hello_get0_random(SSL *s, const unsigned char **out);
21        size_t SSL_client_hello_get0_session_id(SSL *s, const unsigned char **out);
22        size_t SSL_client_hello_get0_ciphers(SSL *s, const unsigned char **out);
23        size_t SSL_client_hello_get0_compression_methods(SSL *s,
24                                                         const unsigned char **out);
25        int SSL_client_hello_get1_extensions_present(SSL *s, int **out,
26                                                     size_t *outlen);
27        int SSL_client_hello_get0_ext(SSL *s, int type, const unsigned char **out,
28                                      size_t *outlen);
29

DESCRIPTION

31       SSL_CTX_set_client_hello_cb() sets the callback function, which is
32       automatically called during the early stages of ClientHello processing
33       on the server.  The argument supplied when setting the callback is
34       passed back to the callback at runtime.  A callback that returns
35       failure (0) will cause the connection to terminate, and callbacks
36       returning failure should indicate what alert value is to be sent in the
37       al parameter.  A callback may also return a negative value to suspend
38       the handshake, and the handshake function will return immediately.
39       SSL_get_error(3) will return SSL_ERROR_WANT_CLIENT_HELLO_CB to indicate
40       that the handshake was suspended.  It is the job of the ClientHello
41       callback to store information about the state of the last call if
42       needed to continue.  On the next call into the handshake function, the
43       ClientHello callback will be called again, and, if it returns success,
44       normal handshake processing will continue from that point.
45
46       SSL_client_hello_isv2() indicates whether the ClientHello was carried
47       in a SSLv2 record and is in the SSLv2 format.  The SSLv2 format has
48       substantial differences from the normal SSLv3 format, including using
49       three bytes per cipher suite, and not allowing extensions.
50       Additionally, the SSLv2 format 'challenge' field is exposed via
51       SSL_client_hello_get0_random(), padded to SSL3_RANDOM_SIZE bytes with
52       zeros if needed.  For SSLv2 format ClientHellos,
53       SSL_client_hello_get0_compression_methods() returns a dummy list that
54       only includes the null compression method, since the SSLv2 format does
55       not include a mechanism by which to negotiate compression.
56
57       SSL_client_hello_get0_random(), SSL_client_hello_get0_session_id(),
58       SSL_client_hello_get0_ciphers(), and
59       SSL_client_hello_get0_compression_methods() provide access to the
60       corresponding ClientHello fields, returning the field length and
61       optionally setting an out pointer to the octets of that field.
62
63       Similarly, SSL_client_hello_get0_ext() provides access to individual
64       extensions from the ClientHello on a per-extension basis.  For the
65       provided wire protocol extension type value, the extension value and
66       length are returned in the output parameters (if present).
67
68       SSL_client_hello_get1_extensions_present() can be used prior to
69       SSL_client_hello_get0_ext(), to determine which extensions are present
70       in the ClientHello before querying for them.  The out and outlen
71       parameters are both required, and on success the caller must release
72       the storage allocated for *out using OPENSSL_free().  The contents of
73       *out is an array of integers holding the numerical value of the TLS
74       extension types in the order they appear in the ClientHello.  *outlen
75       contains the number of elements in the array.  In situations when the
76       ClientHello has no extensions, the function will return success with
77       *out set to NULL and *outlen set to 0.
78

NOTES

80       The ClientHello callback provides a vast window of possibilities for
81       application code to affect the TLS handshake.  A primary use of the
82       callback is to allow the server to examine the server name indication
83       extension provided by the client in order to select an appropriate
84       certificate to present, and make other configuration adjustments
85       relevant to that server name and its configuration.  Such configuration
86       changes can include swapping out the associated SSL_CTX pointer,
87       modifying the server's list of permitted TLS versions, changing the
88       server's cipher list in response to the client's cipher list, etc.
89
90       It is also recommended that applications utilize a ClientHello callback
91       and not use a servername callback, in order to avoid unexpected
92       behavior that occurs due to the relative order of processing between
93       things like session resumption and the historical servername callback.
94
95       The SSL_client_hello_* family of functions may only be called from code
96       executing within a ClientHello callback.
97

RETURN VALUES

99       The application's supplied ClientHello callback returns
100       SSL_CLIENT_HELLO_SUCCESS on success, SSL_CLIENT_HELLO_ERROR on failure,
101       and SSL_CLIENT_HELLO_RETRY to suspend processing.
102
103       SSL_client_hello_isv2() returns 1 for SSLv2-format ClientHellos and 0
104       otherwise.
105
106       SSL_client_hello_get0_random(), SSL_client_hello_get0_session_id(),
107       SSL_client_hello_get0_ciphers(), and
108       SSL_client_hello_get0_compression_methods() return the length of the
109       corresponding ClientHello fields.  If zero is returned, the output
110       pointer should not be assumed to be valid.
111
112       SSL_client_hello_get0_ext() returns 1 if the extension of type 'type'
113       is present, and 0 otherwise.
114
115       SSL_client_hello_get1_extensions_present() returns 1 on success and 0
116       on failure.
117

SEE ALSO

119       ssl(7), SSL_CTX_set_tlsext_servername_callback(3),
120       SSL_bytes_to_cipher_list
121

HISTORY

123       The SSL ClientHello callback, SSL_client_hello_isv2(),
124       SSL_client_hello_get0_random(), SSL_client_hello_get0_session_id(),
125       SSL_client_hello_get0_ciphers(),
126       SSL_client_hello_get0_compression_methods(),
127       SSL_client_hello_get0_ext(), and
128       SSL_client_hello_get1_extensions_present() were added in OpenSSL 1.1.1.
129
131       Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
132
133       Licensed under the OpenSSL license (the "License").  You may not use
134       this file except in compliance with the License.  You can obtain a copy
135       in the file LICENSE in the source distribution or at
136       <https://www.openssl.org/source/license.html>.
137
138
139
1401.1.1i                            2021-07-22    SSL_CTX_SET_CLIENT_HELLO_CB(3)
Impressum