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.
76

NOTES

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

RETURN VALUES

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

SEE ALSO

117       ssl(7), SSL_CTX_set_tlsext_servername_callback(3),
118       SSL_bytes_to_cipher_list
119

HISTORY

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