openssl/util
Benjamin Kaduk 6b1bb98fad Add SSL_CTX early callback
Provide a callback interface that gives the application the ability
to adjust the nascent SSL object at the earliest stage of ClientHello
processing, immediately after extensions have been collected but
before they have been processed.

This is akin to BoringSSL's "select_certificate_cb" (though it is not
API compatible), and as the name indicates, one major use is to examine
the supplied server name indication and select what certificate to
present to the client.  However, it can also be used to make more
sweeping configuration changes to the SSL object according to the
selected server identity and configuration.  That may include adjusting
the permitted TLS versions, swapping out the SSL_CTX object (as is
traditionally done in a tlsext_servername_callback), changing the
server's cipher list, and more.

We also wish to allow an early callback to indicate that it needs to perform
additional work asynchronously and resume processing later.  To that effect,
refactor the second half of tls_process_client_hello() into a subroutine to be
called at the post-processing stage (including the early callback itself), to
allow the callback to result in remaining in the same work stage for a later
call to succeed.  This requires allocating for and storing the CLIENTHELLO_MSG
in the SSL object to be preserved across such calls, but the storage is
reclaimed after ClientHello processing finishes.

Information about the CliehtHello is available to the callback by means of
accessor functions that can only be used from the early callback.  This allows
extensions to make use of the existing internal parsing machinery without
exposing structure internals (e.g., of PACKET), so that applications do not
have to write fragile parsing code.

Applications are encouraged to utilize an early callback and not use
a servername_callback, in order to avoid unexpected behavior that
occurs due to the relative order of processing between things like
session resumption and the historical servername callback.

Also tidy up nearby style by removing unnecessary braces around one-line
conditional bodies.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2279)
2017-02-23 19:40:26 +01:00
..
perl/OpenSSL/Util Move manpages to man[1357] structure. 2016-10-26 13:59:52 -04:00
TLSProxy Update TLSProxy to know about HelloRetryRequest messages 2017-02-14 13:14:25 +00:00
build.info VMS: add [.util]shlib_wrap.exe and its build instructions 2016-09-21 02:40:46 +02:00
check-doc-links.pl Add util/check-doc-links.pl, to be used to check referenses in manuals 2016-11-11 13:06:43 +01:00
ck_errf.pl Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
copy.pl Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
dofile.pl util/dofile.pl: report if a template couldn't be loaded 2016-09-21 01:49:04 +02:00
find-doc-nits.pl Doc nits: callback function typedefs 2017-01-09 16:09:50 -05:00
find-unused-errs GH1278: Removed error code for alerts 2016-07-08 13:28:33 -04:00
fipslink.pl Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
incore Add OpenSSL copyright to .pl files 2016-05-21 08:23:39 -04:00
indent.pro Clean dead macros and defines 2017-01-18 15:19:24 +01:00
libcrypto.num Implementation of the ARIA cipher as described in RFC 5794. 2017-02-21 11:51:45 +01:00
libssl.num Add SSL_CTX early callback 2017-02-23 19:40:26 +01:00
mkbuildinf.pl Copyright consolidation: perl files 2016-04-20 09:45:40 -04:00
mkcerts.sh Fix verify(1) to report failure when verification fails 2016-01-13 17:55:17 -05:00
mkdef.pl Implementation of the ARIA cipher as described in RFC 5794. 2017-02-21 11:51:45 +01:00
mkdir-p.pl utils/mkdir-p: check if dir exists also after mkdir failed 2016-06-23 11:10:29 -04:00
mkerr.pl Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
mkrc.pl Copyright consolidation: perl files 2016-04-20 09:45:40 -04:00
openssl-format-source Simplify indentation of DECLARE_ and IMPLEMENT_ lines 2016-08-18 14:40:37 +02:00
opensslwrap.sh opensslwrap.sh to respect $OPENSSL_ENGINES. 2006-12-29 15:00:36 +00:00
point.sh Updates from 1.0.0-stable 2009-04-06 15:22:01 +00:00
process_docs.pl Fix typo in util/process_docs.pl 2016-11-11 13:07:37 +01:00
selftest.pl Copyright consolidation: perl files 2016-04-20 09:45:40 -04:00
shareable_image_wrap.c.in VMS: add [.util]shlib_wrap.exe and its build instructions 2016-09-21 02:40:46 +02:00
shlib_wrap.sh.in Remove automatic RPATH - adapt shlib_wrap.sh 2016-10-13 02:21:51 +02:00
su-filter.pl Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
with_fallback.pm Copyright consolidation; .pm and Configure 2016-04-20 10:40:05 -04:00