From: Fabian Keil <fk@fabiankeil.de>
Date: Mon, 21 Sep 2020 13:42:04 +0000 (+0200)
Subject: Include wincrypt.h when compiling with OpenSSL on Windows
X-Git-Tag: v_3_0_29~100
X-Git-Url: http://www.privoxy.org/gitweb/@default-cgi@edit-actions-url-form?a=commitdiff_plain;h=01f1bf28d61df7ae3ef376ca6ae4432d68cddd24;p=privoxy.git

Include wincrypt.h when compiling with OpenSSL on Windows

... but undefine X509_NAME and X509_EXTENSIONS.

Fixes:

    x86_64-w64-mingw32-gcc -c -pipe -O2 -Wshadow -DWINVER=0x501   -mwindows
    -Wall -Ipcre  openssl.c -o openssl.o
    In file included from
    P:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:95,
                     from project.h:62,
                     from openssl.c:42:
    P:/msys64/mingw64/include/openssl/ssl.h:1611:5: error: expected
    specifier-qualifier-list before '(' token
     1611 |     X509_EXTENSIONS *tlsext_ocsp_exts;
          |     ^~~~~~~~~~~~~~~

when using OpenSSL 1.0.2.

Reported and partially submitted by: Hớ Hờ Hợ
---

diff --git a/project.h b/project.h
index a9fe8946..7918780f 100644
--- a/project.h
+++ b/project.h
@@ -75,6 +75,11 @@
 #endif /* FEATURE_HTTPS_INSPECTION_MBEDTLS */
 
 #ifdef FEATURE_HTTPS_INSPECTION_OPENSSL
+#ifdef _WIN32
+#include <wincrypt.h>
+#undef X509_NAME
+#undef X509_EXTENSIONS
+#endif
 #include <openssl/ssl.h>
 #include <openssl/bio.h>
 #include <openssl/err.h>