summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-03-07 15:46:58 +0100
committerTomas Mraz <tomas@openssl.org>2022-03-14 09:42:54 +0100
commit38514791b6b8459a98aac4f39e196183cd6332d8 (patch)
tree61fdae210a31d3dd878ed83dc8e1c353f73f22b0 /ssl
parent2722d7482feef2033d27e7ce25394fa4abb8558c (diff)
Replace handling of negative verification result with SSL_set_retry_verify()
Provide a different mechanism to indicate that the application wants to retry the verification. The negative result of the callback function now indicates an error again. Instead the SSL_set_retry_verify() can be called from the callback to indicate that the handshake should be suspended. Fixes #17568 Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17825) (cherry picked from commit dfb39f73132edf56daaad189e6791d1bdb57c4db)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/ssl_lib.c3
-rw-r--r--ssl/statem/statem_clnt.c7
2 files changed, 7 insertions, 3 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 14030f8ebc..50254ad5af 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -2393,6 +2393,9 @@ long SSL_ctrl(SSL *s, int cmd, long larg, void *parg)
return 1;
case SSL_CTRL_GET_RI_SUPPORT:
return s->s3.send_connection_binding;
+ case SSL_CTRL_SET_RETRY_VERIFY:
+ s->rwstate = SSL_RETRY_VERIFY;
+ return 1;
case SSL_CTRL_CERT_FLAGS:
return (s->cert->cert_flags |= larg);
case SSL_CTRL_CLEAR_CERT_FLAGS:
diff --git a/ssl/statem/statem_clnt.c b/ssl/statem/statem_clnt.c
index 4ecfc0b546..bfb90982e8 100644
--- a/ssl/statem/statem_clnt.c
+++ b/ssl/statem/statem_clnt.c
@@ -1859,9 +1859,10 @@ WORK_STATE tls_post_process_server_certificate(SSL *s, WORK_STATE wst)
size_t certidx;
int i;
+ if (s->rwstate == SSL_RETRY_VERIFY)
+ s->rwstate = SSL_NOTHING;
i = ssl_verify_cert_chain(s, s->session->peer_chain);
- if (i == -1) {
- s->rwstate = SSL_RETRY_VERIFY;
+ if (i > 0 && s->rwstate == SSL_RETRY_VERIFY) {
return WORK_MORE_A;
}
/*
@@ -1878,7 +1879,7 @@ WORK_STATE tls_post_process_server_certificate(SSL *s, WORK_STATE wst)
* (less clean) historic behaviour of performing validation if any flag is
* set. The *documented* interface remains the same.
*/
- if (s->verify_mode != SSL_VERIFY_NONE && i == 0) {
+ if (s->verify_mode != SSL_VERIFY_NONE && i <= 0) {
SSLfatal(s, ssl_x509err2alert(s->verify_result),
SSL_R_CERTIFICATE_VERIFY_FAILED);
return WORK_ERROR;