From cdaf072f90399efb9e8e19ee4f387d1425f12274 Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Sun, 21 Nov 2021 20:55:35 +0100 Subject: HTTP client: Fix cleanup of TLS BIO via 'bio_update_fn' callback function Make app_http_tls_cb() tidy up on disconnect the SSL BIO it pushes on connect. Make OSSL_HTTP_close() respect this. Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/17318) --- crypto/http/http_client.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'crypto/http') diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c index ef0114240b..f786f831bf 100644 --- a/crypto/http/http_client.c +++ b/crypto/http/http_client.c @@ -1196,11 +1196,17 @@ BIO *OSSL_HTTP_transfer(OSSL_HTTP_REQ_CTX **prctx, int OSSL_HTTP_close(OSSL_HTTP_REQ_CTX *rctx, int ok) { + BIO *wbio; int ret = 1; - /* callback can be used to clean up TLS session on disconnect */ - if (rctx != NULL && rctx->upd_fn != NULL) - ret = (*rctx->upd_fn)(rctx->wbio, rctx->upd_arg, 0, ok) != NULL; + /* callback can be used to finish TLS session and free its BIO */ + if (rctx != NULL && rctx->upd_fn != NULL) { + wbio = (*rctx->upd_fn)(rctx->wbio, rctx->upd_arg, + 0 /* disconnect */, ok); + ret = wbio != NULL; + if (ret) + rctx->wbio = wbio; + } OSSL_HTTP_REQ_CTX_free(rctx); return ret; } -- cgit v1.2.3