diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2019-05-05 19:23:37 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2019-05-05 21:31:43 +0100 |
commit | 4a1bd6b935ca5c5b70408a60036312d4825fd24e (patch) | |
tree | 266f9a1e9e40ee559b190d77a801613ad704e75c /src | |
parent | 11c4a22b0a2098d2ad7b9d210bc4a1bfc9742ff8 (diff) |
OpenSSL: better handling of $tls_{in,out}_certificate_verified under resumption
Diffstat (limited to 'src')
-rw-r--r-- | src/src/globals.h | 1 | ||||
-rw-r--r-- | src/src/tls-openssl.c | 27 |
2 files changed, 23 insertions, 5 deletions
diff --git a/src/src/globals.h b/src/src/globals.h index 1aacaf7e6..e98ff7fe1 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -108,6 +108,7 @@ typedef struct { BOOL host_resumable:1; BOOL ticket_received:1; #endif + BOOL verify_override:1; /* certificate_verified only due to tls_try_verify_hosts */ } tls_support; extern tls_support tls_in; extern tls_support tls_out; diff --git a/src/src/tls-openssl.c b/src/src/tls-openssl.c index 4b3847712..ee52b7caa 100644 --- a/src/src/tls-openssl.c +++ b/src/src/tls-openssl.c @@ -526,6 +526,7 @@ if (ev) } DEBUG(D_tls) debug_printf("Event-action verify failure overridden " "(host in tls_try_verify_hosts)\n"); + tlsp->verify_override = TRUE; } X509_free(tlsp->peercert); tlsp->peercert = old_cert; @@ -603,6 +604,7 @@ if (preverify_ok == 0) } DEBUG(D_tls) debug_printf("SSL verify failure overridden (host in " "tls_try_verify_hosts)\n"); + tlsp->verify_override = TRUE; } else if (depth != 0) @@ -679,8 +681,9 @@ else tlsp->peercert = X509_dup(cert); /* record failing cert */ return 0; /* reject */ } - DEBUG(D_tls) debug_printf("SSL verify failure overridden (host in " + DEBUG(D_tls) debug_printf("SSL verify name failure overridden (host in " "tls_try_verify_hosts)\n"); + tlsp->verify_override = TRUE; } } @@ -691,7 +694,6 @@ else DEBUG(D_tls) debug_printf("SSL%s verify ok: depth=0 SN=%s\n", *calledp ? "" : " authenticated", dn); - if (!*calledp) tlsp->certificate_verified = TRUE; *calledp = TRUE; } @@ -748,7 +750,7 @@ DEBUG(D_tls) debug_printf("verify_callback_client_dane: %s depth %d %s\n", if (preverify_ok == 1) { - tls_out.dane_verified = tls_out.certificate_verified = TRUE; + tls_out.dane_verified = TRUE; #ifndef DISABLE_OCSP if (client_static_cbinfo->u_ocsp.client.verify_store) { /* client, wanting stapling */ @@ -2153,8 +2155,23 @@ if (tlsp->peercert) { DEBUG(D_tls) debug_printf("X509_NAME_oneline() error\n"); } else { - peerdn[siz-1] = '\0'; - tlsp->peerdn = peerdn; /*XXX a static buffer... */ + int oldpool = store_pool; + + peerdn[siz-1] = '\0'; /* paranoia */ + store_pool = POOL_PERM; + tlsp->peerdn = string_copy(peerdn); + store_pool = oldpool; + + /* We used to set CV in the cert-verify callbacks (either plain or dane) + but they don't get called on session-resumption. So use the official + interface, which uses the resumed value. Unfortunately this claims verified + when it actually failed but we're in try-verify mode, due to us wanting the + knowlege that it failed so needing to have the callback and forcing a + permissive return. If we don't force it, the TLS startup is failed. + Hence the verify_override bodge - though still a problem for resumption. */ + + if (!tlsp->verify_override) + tlsp->certificate_verified = SSL_get_verify_result(ssl) == X509_V_OK; } } |