Skip to content

Commit 6ce19b7

Browse files
DDvOhlandau
authored andcommitted
CMP app and app_http_tls_cb(): pick the right TLS hostname (also without port)
Fixes #20031 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from #20034) (cherry picked from commit 30b9a6e)
1 parent 259c7f6 commit 6ce19b7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

apps/cmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1956,7 +1956,7 @@ static int setup_client_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
19561956
if ((info = OPENSSL_zalloc(sizeof(*info))) == NULL)
19571957
goto err;
19581958
(void)OSSL_CMP_CTX_set_http_cb_arg(ctx, info);
1959-
info->server = opt_server;
1959+
info->server = host;
19601960
info->port = server_port;
19611961
/* workaround for callback design flaw, see #17088: */
19621962
info->use_proxy = proxy_host != NULL;

apps/lib/apps.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,10 @@ BIO *app_http_tls_cb(BIO *bio, void *arg, int connect, int detail)
24742474
if (connect) {
24752475
SSL *ssl;
24762476
BIO *sbio = NULL;
2477+
X509_STORE *ts = SSL_CTX_get_cert_store(ssl_ctx);
2478+
X509_VERIFY_PARAM *vpm = X509_STORE_get0_param(ts);
2479+
const char *host = vpm == NULL ? NULL :
2480+
X509_VERIFY_PARAM_get0_host(vpm, 0 /* first hostname */);
24772481

24782482
/* adapt after fixing callback design flaw, see #17088 */
24792483
if ((info->use_proxy
@@ -2488,8 +2492,8 @@ BIO *app_http_tls_cb(BIO *bio, void *arg, int connect, int detail)
24882492
return NULL;
24892493
}
24902494

2491-
/* adapt after fixing callback design flaw, see #17088 */
2492-
SSL_set_tlsext_host_name(ssl, info->server); /* not critical to do */
2495+
if (vpm != NULL)
2496+
SSL_set_tlsext_host_name(ssl, host /* may be NULL */);
24932497

24942498
SSL_set_connect_state(ssl);
24952499
BIO_set_ssl(sbio, ssl, BIO_CLOSE);

0 commit comments

Comments
 (0)