BUG/MEDIUM: ssl: OCSP must work with BoringSSL
authorEmmanuel Hocdet <ehocdet@club.fr>
Mon, 26 Oct 2020 12:55:30 +0000 (13:55 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Tue, 27 Oct 2020 09:03:16 +0000 (10:03 +0100)
It's a regression from b3201a3e "BUG/MINOR: disable dynamic OCSP load
with BoringSSL". The origin bug is link to 76b4a12 "BUG/MEDIUM: ssl:
memory leak of ocsp data at SSL_CTX_free()": ssl_sock_free_ocsp()
shoud be in #ifndef OPENSSL_IS_BORINGSSL.
To avoid long #ifdef for small code, the BoringSSL part for ocsp load
is isolated in a simple #ifdef.

This must be backported in 2.2 and 2.1

(cherry picked from commit a73a222a9863e5f6763786845c1ff9e7e1038c3c)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit f495e5d6a597e2e1caa965e963ef16103da545db)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>

src/ssl_sock.c

index 0f57517..ca25190 100644 (file)
@@ -1256,7 +1256,6 @@ static void ssl_sock_free_ocsp(struct certificate_ocsp *ocsp)
  * Returns 1 if no ".ocsp" file found, 0 if OCSP status extension is
  * successfully enabled, or -1 in other error case.
  */
-#ifndef OPENSSL_IS_BORINGSSL
 static int ssl_sock_load_ocsp(SSL_CTX *ctx, const struct cert_key_and_chain *ckch)
 {
        X509 *x = NULL, *issuer = NULL;
@@ -1375,15 +1374,15 @@ out:
 
        return ret;
 }
-#else /* OPENSSL_IS_BORINGSSL */
+#endif
+
+#ifdef OPENSSL_IS_BORINGSSL
 static int ssl_sock_load_ocsp(SSL_CTX *ctx, const struct cert_key_and_chain *ckch)
 {
        return SSL_CTX_set_ocsp_response(ctx, (const uint8_t *)ckch->ocsp_response->area, ckch->ocsp_response->data);
 }
 #endif
 
-#endif
-
 
 #if (HA_OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined OPENSSL_NO_TLSEXT && !defined OPENSSL_IS_BORINGSSL)
 
@@ -3493,7 +3492,7 @@ static int ssl_sock_put_ckch_into_ctx(const char *path, const struct cert_key_an
        }
 #endif
 
-#if ((defined SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB && !defined OPENSSL_NO_OCSP) && !defined OPENSSL_IS_BORINGSSL)
+#if ((defined SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB && !defined OPENSSL_NO_OCSP) || defined OPENSSL_IS_BORINGSSL)
        /* Load OCSP Info into context */
        if (ckch->ocsp_response) {
                if (ssl_sock_load_ocsp(ctx, ckch) < 0) {