From 01f1bf28d61df7ae3ef376ca6ae4432d68cddd24 Mon Sep 17 00:00:00 2001
From: Fabian Keil <fk@fabiankeil.de>
Date: Mon, 21 Sep 2020 15:42:04 +0200
Subject: [PATCH] Include wincrypt.h when compiling with OpenSSL on Windows
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

... 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ợ
---
 project.h | 5 +++++
 1 file changed, 5 insertions(+)

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>
-- 
2.49.0