openssl/ssl
Dr. David von Oheimb 0c3eb2793b TLS client: allow cert verify callback return -1 for SSL_ERROR_WANT_RETRY_VERIFY
The client-side cert verification callback function may not only return
as usual for success or 0 for failure, but also -1,
typically on failure verifying the server certificate.
This makes the handshake suspend and return control to the calling application
with SSL_ERROR_WANT_RETRY_VERIFY.
The app can for instance fetch further certificates or cert status information
needed for the verification.
Calling SSL_connect() again resumes the connection attempt
by retrying the server certificate verification step.
This process may even be repeated if need be.

The core implementation of the feature is in ssl/statem/statem_clnt.c,
splitting tls_process_server_certificate() into a preparation step
that just copies the certificates received from the server to s->session->peer_chain
(rather than having them in a local variable at first) and returns to the state machine,
and a post-processing step in tls_post_process_server_certificate() that can be repeated:
Try verifying the current contents of s->session->peer_chain basically as before,
but give the verification callback function the chance to pause connecting and
make the TLS state machine later call tls_post_process_server_certificate() again.
Otherwise processing continues as usual.

The documentation of the new feature is added to SSL_CTX_set_cert_verify_callback.pod
and SSL_want.pod.

This adds two tests:
* A generic test in test/helpers/handshake.c
  on the usability of the new server cert verification retry feature.
  It is triggered via test/ssl-tests/03-custom_verify.cnf.in (while the bulky auto-
  generated changes to test/ssl-tests/03-custom_verify.cnf can be basically ignored).
* A test in test/sslapitest.c that demonstrates the effectiveness of the approach
  for augmenting the cert chain provided by the server in between SSL_connect() calls.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13906)
2021-01-26 17:09:13 +01:00
..
record Ensure DTLS free functions can handle NULL 2021-01-08 10:26:26 +00:00
statem TLS client: allow cert verify callback return -1 for SSL_ERROR_WANT_RETRY_VERIFY 2021-01-26 17:09:13 +01:00
bio_ssl.c
build.info Modify the ERR init functions to use the internal ERR string loaders 2020-11-24 15:21:44 +01:00
d1_lib.c Ensure DTLS free functions can handle NULL 2021-01-08 10:26:26 +00:00
d1_msg.c Update copyright year 2020-11-26 14:18:57 +00:00
d1_srtp.c
ktls.c ktls: Initial support for ChaCha20-Poly1305 2021-01-20 18:05:41 +01:00
methods.c
pqueue.c Update copyright year 2020-11-26 14:18:57 +00:00
s3_cbc.c
s3_enc.c Clean away extraneous library specific FETCH_FAILED reason codes 2021-01-12 19:02:11 +01:00
s3_lib.c Avoid using OSSL_PKEY_PARAM_GROUP_NAME when the key might be legacy 2021-01-26 15:26:49 +01:00
s3_msg.c Update copyright year 2020-11-26 14:18:57 +00:00
ssl_asn1.c Update copyright year 2020-11-26 14:18:57 +00:00
ssl_cert_table.h
ssl_cert.c Add X509_NAME_hash_ex() to be able to check if it failed due to unsupported SHA1 2021-01-13 09:09:36 +01:00
ssl_ciph.c Remove extra space. 2021-01-07 17:38:56 +01:00
ssl_conf.c Implement a replacement for SSL_set_tmp_dh() 2020-11-18 14:14:52 +00:00
ssl_err_legacy.c Modify the ERR init functions to use the internal ERR string loaders 2020-11-24 15:21:44 +01:00
ssl_err.c Clean away extraneous library specific FETCH_FAILED reason codes 2021-01-12 19:02:11 +01:00
ssl_init.c Modify the ERR init functions to use the internal ERR string loaders 2020-11-24 15:21:44 +01:00
ssl_lib.c TLS client: allow cert verify callback return -1 for SSL_ERROR_WANT_RETRY_VERIFY 2021-01-26 17:09:13 +01:00
ssl_local.h Avoid using OSSL_PKEY_PARAM_GROUP_NAME when the key might be legacy 2021-01-26 15:26:49 +01:00
ssl_mcnf.c SSL: refactor all SSLfatal() calls 2020-11-11 12:12:23 +01:00
ssl_rsa_legacy.c Deprecate RSA harder 2020-11-18 23:38:34 +01:00
ssl_rsa.c Don't copy parameters on setting a key in libssl 2021-01-22 09:30:53 +00:00
ssl_sess.c SSL: refactor all SSLfatal() calls 2020-11-11 12:12:23 +01:00
ssl_stat.c
ssl_txt.c
ssl_utst.c
sslerr.h Update copyright year 2020-11-26 14:18:57 +00:00
t1_enc.c Clean away extraneous library specific FETCH_FAILED reason codes 2021-01-12 19:02:11 +01:00
t1_lib.c Add EVP_PKEY functions to get EC conv form and field type 2021-01-26 15:26:17 +01:00
t1_trce.c
tls13_enc.c Clean away extraneous library specific FETCH_FAILED reason codes 2021-01-12 19:02:11 +01:00
tls_depr.c Avoid using OSSL_PKEY_PARAM_GROUP_NAME when the key might be legacy 2021-01-26 15:26:49 +01:00
tls_srp.c SSL: refactor all SSLfatal() calls 2020-11-11 12:12:23 +01:00