]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/man3/SSL_CTX_set_client_hello_cb.3
MFC: r359486
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / man3 / SSL_CTX_set_client_hello_cb.3
1 .\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.40)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{\
60 .    if \nF \{\
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{\
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
74 .    \" fudge factors for nroff and troff
75 .if n \{\
76 .    ds #H 0
77 .    ds #V .8m
78 .    ds #F .3m
79 .    ds #[ \f1
80 .    ds #] \fP
81 .\}
82 .if t \{\
83 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
84 .    ds #V .6m
85 .    ds #F 0
86 .    ds #[ \&
87 .    ds #] \&
88 .\}
89 .    \" simple accents for nroff and troff
90 .if n \{\
91 .    ds ' \&
92 .    ds ` \&
93 .    ds ^ \&
94 .    ds , \&
95 .    ds ~ ~
96 .    ds /
97 .\}
98 .if t \{\
99 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
105 .\}
106 .    \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 .    \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 .    \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
121 \{\
122 .    ds : e
123 .    ds 8 ss
124 .    ds o a
125 .    ds d- d\h'-1'\(ga
126 .    ds D- D\h'-1'\(hy
127 .    ds th \o'bp'
128 .    ds Th \o'LP'
129 .    ds ae ae
130 .    ds Ae AE
131 .\}
132 .rm #[ #] #H #V #F C
133 .\" ========================================================================
134 .\"
135 .IX Title "SSL_CTX_SET_CLIENT_HELLO_CB 3"
136 .TH SSL_CTX_SET_CLIENT_HELLO_CB 3 "2020-03-31" "1.1.1f" "OpenSSL"
137 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
139 .if n .ad l
140 .nh
141 .SH "NAME"
142 SSL_CTX_set_client_hello_cb, SSL_client_hello_cb_fn, SSL_client_hello_isv2, SSL_client_hello_get0_legacy_version, SSL_client_hello_get0_random, SSL_client_hello_get0_session_id, SSL_client_hello_get0_ciphers, SSL_client_hello_get0_compression_methods, SSL_client_hello_get1_extensions_present, SSL_client_hello_get0_ext \- callback functions for early server\-side ClientHello processing
143 .SH "SYNOPSIS"
144 .IX Header "SYNOPSIS"
145 .Vb 10
146 \& typedef int (*SSL_client_hello_cb_fn)(SSL *s, int *al, void *arg);
147 \& void SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn *f,
148 \&                                  void *arg);
149 \& int SSL_client_hello_isv2(SSL *s);
150 \& unsigned int SSL_client_hello_get0_legacy_version(SSL *s);
151 \& size_t SSL_client_hello_get0_random(SSL *s, const unsigned char **out);
152 \& size_t SSL_client_hello_get0_session_id(SSL *s, const unsigned char **out);
153 \& size_t SSL_client_hello_get0_ciphers(SSL *s, const unsigned char **out);
154 \& size_t SSL_client_hello_get0_compression_methods(SSL *s,
155 \&                                                  const unsigned char **out);
156 \& int SSL_client_hello_get1_extensions_present(SSL *s, int **out,
157 \&                                              size_t *outlen);
158 \& int SSL_client_hello_get0_ext(SSL *s, int type, const unsigned char **out,
159 \&                               size_t *outlen);
160 .Ve
161 .SH "DESCRIPTION"
162 .IX Header "DESCRIPTION"
163 \&\fBSSL_CTX_set_client_hello_cb()\fR sets the callback function, which is automatically
164 called during the early stages of ClientHello processing on the server.
165 The argument supplied when setting the callback is passed back to the
166 callback at runtime.  A callback that returns failure (0) will cause the
167 connection to terminate, and callbacks returning failure should indicate
168 what alert value is to be sent in the \fBal\fR parameter.  A callback may
169 also return a negative value to suspend the handshake, and the handshake
170 function will return immediately.  \fBSSL_get_error\fR\|(3) will return
171 \&\s-1SSL_ERROR_WANT_CLIENT_HELLO_CB\s0 to indicate that the handshake was suspended.
172 It is the job of the ClientHello callback to store information about the state
173 of the last call if needed to continue.  On the next call into the handshake
174 function, the ClientHello callback will be called again, and, if it returns
175 success, normal handshake processing will continue from that point.
176 .PP
177 \&\fBSSL_client_hello_isv2()\fR indicates whether the ClientHello was carried in a
178 SSLv2 record and is in the SSLv2 format.  The SSLv2 format has substantial
179 differences from the normal SSLv3 format, including using three bytes per
180 cipher suite, and not allowing extensions.  Additionally, the SSLv2 format
181 \&'challenge' field is exposed via \fBSSL_client_hello_get0_random()\fR, padded to
182 \&\s-1SSL3_RANDOM_SIZE\s0 bytes with zeros if needed.  For SSLv2 format ClientHellos,
183 \&\fBSSL_client_hello_get0_compression_methods()\fR returns a dummy list that only includes
184 the null compression method, since the SSLv2 format does not include a
185 mechanism by which to negotiate compression.
186 .PP
187 \&\fBSSL_client_hello_get0_random()\fR, \fBSSL_client_hello_get0_session_id()\fR,
188 \&\fBSSL_client_hello_get0_ciphers()\fR, and
189 \&\fBSSL_client_hello_get0_compression_methods()\fR provide access to the corresponding
190 ClientHello fields, returning the field length and optionally setting an out
191 pointer to the octets of that field.
192 .PP
193 Similarly, \fBSSL_client_hello_get0_ext()\fR provides access to individual extensions
194 from the ClientHello on a per-extension basis.  For the provided wire
195 protocol extension type value, the extension value and length are returned
196 in the output parameters (if present).
197 .PP
198 \&\fBSSL_client_hello_get1_extensions_present()\fR can be used prior to
199 \&\fBSSL_client_hello_get0_ext()\fR, to determine which extensions are present in the
200 ClientHello before querying for them.  The \fBout\fR and \fBoutlen\fR parameters are
201 both required, and on success the caller must release the storage allocated for
202 \&\fB*out\fR using \fBOPENSSL_free()\fR.  The contents of \fB*out\fR is an array of integers
203 holding the numerical value of the \s-1TLS\s0 extension types in the order they appear
204 in the ClientHello.  \fB*outlen\fR contains the number of elements in the array.
205 In situations when the ClientHello has no extensions, the function will return
206 success with \fB*out\fR set to \s-1NULL\s0 and \fB*outlen\fR set to 0.
207 .SH "NOTES"
208 .IX Header "NOTES"
209 The ClientHello callback provides a vast window of possibilities for application
210 code to affect the \s-1TLS\s0 handshake.  A primary use of the callback is to
211 allow the server to examine the server name indication extension provided
212 by the client in order to select an appropriate certificate to present,
213 and make other configuration adjustments relevant to that server name
214 and its configuration.  Such configuration changes can include swapping out
215 the associated \s-1SSL_CTX\s0 pointer, modifying the server's list of permitted \s-1TLS\s0
216 versions, changing the server's cipher list in response to the client's
217 cipher list, etc.
218 .PP
219 It is also recommended that applications utilize a ClientHello callback and
220 not use a servername callback, in order to avoid unexpected behavior that
221 occurs due to the relative order of processing between things like session
222 resumption and the historical servername callback.
223 .PP
224 The SSL_client_hello_* family of functions may only be called from code executing
225 within a ClientHello callback.
226 .SH "RETURN VALUES"
227 .IX Header "RETURN VALUES"
228 The application's supplied ClientHello callback returns
229 \&\s-1SSL_CLIENT_HELLO_SUCCESS\s0 on success, \s-1SSL_CLIENT_HELLO_ERROR\s0 on failure, and
230 \&\s-1SSL_CLIENT_HELLO_RETRY\s0 to suspend processing.
231 .PP
232 \&\fBSSL_client_hello_isv2()\fR returns 1 for SSLv2\-format ClientHellos and 0 otherwise.
233 .PP
234 \&\fBSSL_client_hello_get0_random()\fR, \fBSSL_client_hello_get0_session_id()\fR,
235 \&\fBSSL_client_hello_get0_ciphers()\fR, and
236 \&\fBSSL_client_hello_get0_compression_methods()\fR return the length of the
237 corresponding ClientHello fields.  If zero is returned, the output pointer
238 should not be assumed to be valid.
239 .PP
240 \&\fBSSL_client_hello_get0_ext()\fR returns 1 if the extension of type 'type' is present, and
241 0 otherwise.
242 .PP
243 \&\fBSSL_client_hello_get1_extensions_present()\fR returns 1 on success and 0 on failure.
244 .SH "SEE ALSO"
245 .IX Header "SEE ALSO"
246 \&\fBssl\fR\|(7), \fBSSL_CTX_set_tlsext_servername_callback\fR\|(3),
247 SSL_bytes_to_cipher_list
248 .SH "HISTORY"
249 .IX Header "HISTORY"
250 The \s-1SSL\s0 ClientHello callback, \fBSSL_client_hello_isv2()\fR,
251 \&\fBSSL_client_hello_get0_random()\fR, \fBSSL_client_hello_get0_session_id()\fR,
252 \&\fBSSL_client_hello_get0_ciphers()\fR, \fBSSL_client_hello_get0_compression_methods()\fR,
253 \&\fBSSL_client_hello_get0_ext()\fR, and \fBSSL_client_hello_get1_extensions_present()\fR
254 were added in OpenSSL 1.1.1.
255 .SH "COPYRIGHT"
256 .IX Header "COPYRIGHT"
257 Copyright 2017\-2019 The OpenSSL Project Authors. All Rights Reserved.
258 .PP
259 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
260 this file except in compliance with the License.  You can obtain a copy
261 in the file \s-1LICENSE\s0 in the source distribution or at
262 <https://www.openssl.org/source/license.html>.