GEODE-6568: Use OpenSSL from local install (#465)

* Support OpenSSL 1.0.x and 1.1.x with compat header.
* Install openssl-devel package on RHEL
* Install libssl-dev package on Ubuntu
* Install OpenSSL and headers on Windows.
* Update BUILDING and Docker for Travis
diff --git a/BUILDING.md b/BUILDING.md
index 4ddd014..5d258af 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -4,6 +4,7 @@
 * [CMake 3.12](https://cmake.org/) or newer
 * C++11 compiler *(see platform specific requirements)*
 * [Doxygen 8.11](http://www.stack.nl/~dimitri/doxygen/download.html) *(for building source documentation)*
+* [OpenSSL](https://www.openssl.org) *(for building source documentation)*
 * [Apache Geode](http://geode.apache.org/releases/) binaries installed or available to link against
 
 ### Platform-Specific Prerequisites
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22c801c..5118e1e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -338,7 +338,10 @@
 	FOLDER test-common
 )
 
+find_package(OpenSSL REQUIRED)
+
 add_subdirectory(dependencies)
+add_subdirectory(openssl-compat)
 add_subdirectory(cppcache)
 add_subdirectory(cryptoimpl)
 add_subdirectory(dhimpl)
diff --git a/clicache/integration-test/CMakeLists.txt b/clicache/integration-test/CMakeLists.txt
index 1e16d35..ca78f83 100644
--- a/clicache/integration-test/CMakeLists.txt
+++ b/clicache/integration-test/CMakeLists.txt
@@ -56,7 +56,7 @@
     )
 endmacro()
 
-foreach( lib OpenSSL::SSL SQLite::sqlite3 )
+foreach( lib SQLite::sqlite3 )
   get_target_property(runtime_path ${lib} INTERFACE_RUNTIME_DIR)
   set(PATH ${PATH} ${runtime_path})
 endforeach()
diff --git a/clicache/integration-test2/CMakeLists.txt b/clicache/integration-test2/CMakeLists.txt
index b8a3e78..565afeb 100644
--- a/clicache/integration-test2/CMakeLists.txt
+++ b/clicache/integration-test2/CMakeLists.txt
@@ -100,9 +100,6 @@
 add_dependencies(${PROJECT_NAME} nuget-restore)
 
 add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E copy_directory
-    $<SHELL_PATH:$<TARGET_GENEX_EVAL:OpenSSL::SSL,$<TARGET_PROPERTY:OpenSSL::SSL,INTERFACE_RUNTIME_DIR>>>
-    $<SHELL_PATH:$<TARGET_FILE_DIR:${PROJECT_NAME}>>
   COMMAND ${CMAKE_COMMAND} -E copy_if_different
     $<SHELL_PATH:$<TARGET_FILE:cryptoImpl>>
     $<$<CONFIG:Debug>:$<SHELL_PATH:$<TARGET_PDB_FILE:cryptoImpl>>>
diff --git a/cppcache/integration-test/CMakeLists.txt b/cppcache/integration-test/CMakeLists.txt
index 0daaeb9..b783211 100644
--- a/cppcache/integration-test/CMakeLists.txt
+++ b/cppcache/integration-test/CMakeLists.txt
@@ -76,7 +76,7 @@
 endmacro()
 
 # Add lazy loaded shared library paths to test environment
-foreach( lib OpenSSL::SSL SQLite::sqlite3 )
+foreach( lib SQLite::sqlite3 )
   get_target_property(library_path ${lib} INTERFACE_LIBRARY_DIR)
   set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${library_path})
   get_target_property(runtime_path ${lib} INTERFACE_RUNTIME_DIR)
diff --git a/cryptoimpl/CMakeLists.txt b/cryptoimpl/CMakeLists.txt
index 3ae1575..5d4a609 100644
--- a/cryptoimpl/CMakeLists.txt
+++ b/cryptoimpl/CMakeLists.txt
@@ -21,7 +21,8 @@
   DHImpl.cpp
   Ssl.hpp
   SSLImpl.hpp
-  SSLImpl.cpp)
+  SSLImpl.cpp
+)
 
 include(GenerateExportHeader)
 generate_export_header(cryptoImpl)
@@ -37,6 +38,7 @@
 
 target_link_libraries(cryptoImpl
   PRIVATE
+    openssl-compat
     ACE::ACE_SSL
     _WarningsAsError
   PUBLIC
diff --git a/cryptoimpl/DHImpl.cpp b/cryptoimpl/DHImpl.cpp
index fb1aadf..9db49f7 100644
--- a/cryptoimpl/DHImpl.cpp
+++ b/cryptoimpl/DHImpl.cpp
@@ -17,6 +17,7 @@
 
 #include "DHImpl.hpp"
 
+#include <openssl-compat.h>
 #include <openssl/aes.h>
 #include <openssl/asn1.h>
 #include <openssl/err.h>
diff --git a/dependencies/ACE/CMakeLists.txt b/dependencies/ACE/CMakeLists.txt
index f5129b9..3799cf7 100644
--- a/dependencies/ACE/CMakeLists.txt
+++ b/dependencies/ACE/CMakeLists.txt
@@ -16,7 +16,6 @@
 project( ACE VERSION 6.5.3 LANGUAGES NONE )
 
 set( SHA256 de20bdbfcbcf7d67836e9a2c0875e4eb348a1153e19b83392608330fec3c056a )
-set( DEPENDS OpenSSL::SSL )
 
 if ("SunOS" STREQUAL ${CMAKE_SYSTEM_NAME})
   set( ACE_PLATFORM sunos5_sunc++ )
@@ -42,9 +41,8 @@
   message( FATAL_ERROR "ACE_PLATFORM unset for ${CMAKE_SYSTEM_NAME}" )
 endif()
 
-
-set( OPENSSL_ROOT $<TARGET_PROPERTY:OpenSSL::SSL,INTERFACE_INCLUDE_DIRECTORIES>/.. )
-
+find_package(OpenSSL REQUIRED)
+set( OPENSSL_ROOT ${OPENSSL_INCLUDE_DIR}/.. )
 
 if (${WIN32})
   if (64 EQUAL ${BUILD_BITS})
diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt
index a422e23..b5fbe29 100644
--- a/dependencies/CMakeLists.txt
+++ b/dependencies/CMakeLists.txt
@@ -19,7 +19,6 @@
 find_package(Patch REQUIRED)
 
 add_subdirectory(	libxml2 )
-add_subdirectory(	openssl )
 add_subdirectory(	ACE )
 add_subdirectory(	boost )
 add_subdirectory(	sqlite )
diff --git a/dependencies/doxygen/CMakeLists.txt b/dependencies/doxygen/CMakeLists.txt
index f9157f7..c46f8ac 100644
--- a/dependencies/doxygen/CMakeLists.txt
+++ b/dependencies/doxygen/CMakeLists.txt
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-project( doxygen VERSION 1.8 LANGUAGES NONE )
+project( doxygen VERSION 1.6 LANGUAGES NONE )
 # used to compile documents
 
 # Not a runtime requirement, so look for existing installation.
diff --git a/dependencies/openssl/CMakeLists.txt b/dependencies/openssl/CMakeLists.txt
deleted file mode 100644
index 9587e00..0000000
--- a/dependencies/openssl/CMakeLists.txt
+++ /dev/null
@@ -1,120 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-project( openssl LANGUAGES NONE )
-
-set( VERSION 1.1.1a )
-set( SHA256 fc20130f8b7cbd2fb918b2f14e2f429e109c31ddd0fb38fc5d71d9ffed3f9f41 )
-
-if ("SunOS" STREQUAL ${CMAKE_SYSTEM_NAME})
-  # No debug for Solaris without patching Configure
-  if ("i386" STREQUAL ${CMAKE_SYSTEM_PROCESSOR})
-    if (64 EQUAL ${BUILD_BITS})
-      set( openssl_PLATFORM solaris64-x86_64-cc )
-    else()
-      set( openssl_PLATFORM solaris-x86-cc )
-    endif()
-  elseif ("sparc" STREQUAL ${CMAKE_SYSTEM_PROCESSOR})
-    if (64 EQUAL ${BUILD_BITS})
-      set( openssl_PLATFORM solaris64-sparcv9-cc )
-    else()
-      set( openssl_PLATFORM solaris-sparcv9-cc )
-    endif()
-  endif()
-elseif ("Linux" STREQUAL ${CMAKE_SYSTEM_NAME})
-  if (64 EQUAL ${BUILD_BITS})
-    set( openssl_PLATFORM $<$<CONFIG:Debug>:debug->linux-x86_64 )
-  else()
-    set( openssl_PLATFORM $<$<CONFIG:Debug>:debug->linux-elf )
-    set( openssl_CONFIGURE_FLAGS ${openssl_CONFIGURE_FLAGS} -m32 )
-  endif()
-  if ("Clang" STREQUAL ${CMAKE_CXX_COMPILER_ID})
-    set( openssl_PLATFORM ${openssl_PLATFORM}-clang )
-  endif()
-elseif ("Darwin" STREQUAL ${CMAKE_SYSTEM_NAME})
-  # No debug for OS X without patching Configure
-  set( openssl_PLATFORM darwin64-x86_64-cc )
-elseif ("Windows" STREQUAL ${CMAKE_SYSTEM_NAME})
-  if (64 EQUAL ${BUILD_BITS})
-    set( openssl_PLATFORM $<$<CONFIG:Debug>:debug->VC-WIN64A no-asm )
-  else()
-    set( openssl_PLATFORM $<$<CONFIG:Debug>:debug->VC-WIN32 no-asm)
-  endif()
-endif()
-
-if (NOT DEFINED openssl_PLATFORM)
-  message( FATAL_ERROR "openssl_PLATFORM unset for ${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
-endif()
-
-if (${WIN32})
-  find_package(Perl REQUIRED)
-  # Keeps separate release/debug objects in build script
-  set ( _CONFIGURE_COMMAND ${PERL_EXECUTABLE} Configure ${openssl_PLATFORM} --prefix=<INSTALL_DIR>/$<CONFIG> --openssldir=<INSTALL_DIR>/$<CONFIG> ${openssl_CONFIGURE_FLAGS} )
-  set ( _BUILD_COMMAND nmake )
-  set ( _INSTALL_COMMAND nmake install_sw )
-else()
-   # TODO Configure trips up without MAKE
-  set ( _CONFIGURE_COMMAND MAKE=$(MAKE) ./Configure threads zlib shared --prefix=<INSTALL_DIR>/$<CONFIG> ${openssl_CONFIGURE_FLAGS} ${openssl_PLATFORM} )
-  set ( _BUILD_COMMAND $(MAKE) all )
-  set ( _INSTALL_COMMAND $(MAKE) install_sw )
-endif()
-
-set( EXTERN ${PROJECT_NAME}-extern )
-include(ExternalProject)
-ExternalProject_Add( ${EXTERN}
-   URL "https://www.openssl.org/source/openssl-${VERSION}.tar.gz"
-   URL_HASH SHA256=${SHA256}
-   UPDATE_COMMAND ""
-   BUILD_IN_SOURCE 1
-   CONFIGURE_COMMAND "${_CONFIGURE_COMMAND}"
-   BUILD_COMMAND "${_BUILD_COMMAND}"
-   INSTALL_COMMAND "${_INSTALL_COMMAND}"
-# TODO   TEST_COMMAND $(MAKE) test
-)
-
-ExternalProject_Get_Property( ${EXTERN} INSTALL_DIR )
-set(INSTALL_DIR "${INSTALL_DIR}/$<CONFIG>")
-
-if (${WIN32})
-  set( CMAKE_SHARED_LIBRARY_PREFIX lib )
-else()
-  set( CMAKE_LINK_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
-endif()
-
-add_library(OpenSSL_SSL INTERFACE)
-target_include_directories(OpenSSL_SSL SYSTEM INTERFACE
-  $<BUILD_INTERFACE:${INSTALL_DIR}/include>
-)
-target_link_libraries(OpenSSL_SSL INTERFACE
-  ${INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}ssl${CMAKE_LINK_LIBRARY_SUFFIX}
-)
-add_dependencies(OpenSSL_SSL ${EXTERN})
-
-add_library(OpenSSL_Crypto INTERFACE)
-target_include_directories(OpenSSL_Crypto SYSTEM INTERFACE
-  $<BUILD_INTERFACE:${INSTALL_DIR}/include>
-)
-target_link_libraries(OpenSSL_Crypto INTERFACE
-  ${INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}crypto${CMAKE_LINK_LIBRARY_SUFFIX}
-)
-add_dependencies(OpenSSL_Crypto ${EXTERN})
-
-set_target_properties(OpenSSL_SSL OpenSSL_Crypto PROPERTIES
-  INTERFACE_LIBRARY_DIR ${INSTALL_DIR}/lib
-  INTERFACE_RUNTIME_DIR ${INSTALL_DIR}/bin
-)
-
-add_library(OpenSSL::SSL ALIAS OpenSSL_SSL)
-add_library(OpenSSL::Crypto ALIAS OpenSSL_Crypto)
diff --git a/dhimpl/CMakeLists.txt b/dhimpl/CMakeLists.txt
index d256d5d..538b9f9 100644
--- a/dhimpl/CMakeLists.txt
+++ b/dhimpl/CMakeLists.txt
@@ -13,15 +13,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-cmake_minimum_required(VERSION 3.10)
 project(DHImpl LANGUAGES CXX)
 
-file(GLOB_RECURSE SOURCES "*.cpp")
-
-add_library(DHImpl SHARED ${SOURCES})
+add_library(DHImpl SHARED
+  DHImpl.cpp
+  DHImpl.hpp
+)
 
 set_target_properties(DHImpl PROPERTIES
-  FOLDER cpp/test/integration)
+  FOLDER cpp/test/integration
+)
 
 include(GenerateExportHeader)
 generate_export_header(DHImpl)
@@ -37,6 +38,7 @@
     OpenSSL::Crypto
     c++11
   PRIVATE
+    openssl-compat
     _WarningsAsError
 )
 
diff --git a/dhimpl/DHImpl.hpp b/dhimpl/DHImpl.hpp
index 8270282..c2b2229 100644
--- a/dhimpl/DHImpl.hpp
+++ b/dhimpl/DHImpl.hpp
@@ -20,9 +20,11 @@
  * limitations under the License.
  */
 
-#include <openssl/dh.h>
+#include <openssl-compat.h>
 #include <openssl/asn1t.h>
+#include <openssl/dh.h>
 #include <openssl/x509.h>
+
 #include <string>
 #include <vector>
 
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 0e560a6..c60d3c1 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -22,6 +22,8 @@
         apt-get install -y \
             libc++-dev \
             libc++abi-dev \
+            libssl-dev \
+            zlib1g-dev \
             clang-${CLANG_VERSION} \
             clang-tidy-${CLANG_VERSION} \
             clang-format-${CLANG_VERSION} \
@@ -30,8 +32,7 @@
             git \
             graphviz \
             openjdk-8-jdk \
-            wget \
-            zlib1g-dev && \
+            wget && \
         rm -rf /var/lib/apt/lists/* && \
         update-alternatives --install /usr/bin/clang         clang         /usr/bin/clang-${CLANG_VERSION} 999 && \
         update-alternatives --install /usr/bin/clang++       clang++       /usr/bin/clang++-${CLANG_VERSION} 999 && \
diff --git a/openssl-compat/CMakeLists.txt b/openssl-compat/CMakeLists.txt
new file mode 100644
index 0000000..20ec26e
--- /dev/null
+++ b/openssl-compat/CMakeLists.txt
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+# 
+#      http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+project(openssl-compat LANGUAGES CXX)
+
+add_library(openssl-compat INTERFACE)
+
+target_include_directories(openssl-compat
+  INTERFACE
+    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+)
+
+find_package(OpenSSL COMPONENTS Crypto)
+
+target_link_libraries(openssl-compat
+  INTERFACE
+    OpenSSL::Crypto
+)
diff --git a/openssl-compat/openssl-compat.h b/openssl-compat/openssl-compat.h
new file mode 100644
index 0000000..87dfbab
--- /dev/null
+++ b/openssl-compat/openssl-compat.h
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OPENSSL_COMPAT_H
+#define OPENSSL_COMPAT_H
+
+#include <openssl/opensslv.h>
+
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+
+#include <openssl/dh.h>
+#include <openssl/evp.h>
+#include <openssl/x509.h>
+
+static inline void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q,
+                               const BIGNUM **g) {
+  if (p) *p = dh->p;
+  if (q) *q = dh->q;
+  if (g) *g = dh->g;
+}
+
+static inline void DH_get0_key(const DH *dh, const BIGNUM **pub_key,
+                               const BIGNUM **priv_key) {
+  if (pub_key) *pub_key = dh->pub_key;
+  if (priv_key) *priv_key = dh->priv_key;
+}
+
+static inline int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) {
+  if (!(dh->pub_key || pub_key)) {
+    return 0;
+  }
+
+  if (pub_key) {
+    BN_free(dh->pub_key);
+    dh->pub_key = pub_key;
+  }
+  if (priv_key) {
+    BN_free(dh->priv_key);
+    dh->priv_key = priv_key;
+  }
+
+  return 1;
+}
+
+static inline int DH_set_length(DH *dh, long length) {
+  dh->length = length;
+  return 1;
+}
+
+static inline EVP_MD_CTX *EVP_MD_CTX_new(void) {
+  return reinterpret_cast<EVP_MD_CTX *>(OPENSSL_malloc(sizeof(EVP_MD_CTX)));
+}
+
+static inline void EVP_MD_CTX_free(EVP_MD_CTX *ctx) {
+  EVP_MD_CTX_cleanup(ctx);
+  OPENSSL_free(ctx);
+}
+
+static inline int EVP_PKEY_up_ref(EVP_PKEY *pkey) {
+  return CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
+}
+
+static inline void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *,
+                                   const void **, const X509_ALGOR *algor) {
+  *paobj = algor->algorithm;
+}
+
+#define X509_F_X509_PUBKEY_DECODE X509_F_X509_PUBKEY_GET
+
+#endif /* OPENSSL_VERSION_NUMBER */
+
+#endif /* OPENSSL_COMPAT_H */
diff --git a/packer/build-windows.json b/packer/build-windows.json
index 20020b2..6d96e72 100644
--- a/packer/build-windows.json
+++ b/packer/build-windows.json
@@ -55,6 +55,17 @@
       ]
     },
     {
+      "type":"file",
+      "source":"windows/Packer.psm1",
+      "destination":"Documents/WindowsPowerShell/Modules/Packer/Packer.psm1"
+    },
+    {
+      "type": "powershell",
+      "scripts": [
+        "windows/install-openssl.ps1"
+      ]
+    },
+    {
       "type": "powershell",
       "scripts": [
         "windows/add-user-build.ps1"
diff --git a/packer/rhel/install-build-rpms.sh b/packer/rhel/install-build-rpms.sh
index 8e0c78d..08cb45d 100644
--- a/packer/rhel/install-build-rpms.sh
+++ b/packer/rhel/install-build-rpms.sh
@@ -17,4 +17,4 @@
 
 set -x -e -o pipefail
 
-yum install -y git2u make doxygen zlib-devel patch
\ No newline at end of file
+yum install -y git2u make doxygen zlib-devel patch openssl-devel
\ No newline at end of file
diff --git a/packer/ubuntu/install-packages.sh b/packer/ubuntu/install-packages.sh
index 6466945..f3e803f 100644
--- a/packer/ubuntu/install-packages.sh
+++ b/packer/ubuntu/install-packages.sh
@@ -17,6 +17,17 @@
 
 set -x -e -o pipefail
 
-apt-get -y install libc++-dev libc++abi-dev wget doxygen openjdk-8-jdk zlib1g-dev graphviz build-essential python python-pip
+apt-get -y install \
+    build-essential \
+    libc++-dev \
+    libc++abi-dev \
+    zlib1g-dev \
+    libssl-dev \
+    wget \
+    doxygen \
+    graphviz \
+    openjdk-8-jdk \
+    python \
+    python-pip
 
 pip install --upgrade pip
diff --git a/packer/windows/install-gemfire.ps1 b/packer/windows/install-gemfire.ps1
index d228157..1ea3e26 100644
--- a/packer/windows/install-gemfire.ps1
+++ b/packer/windows/install-gemfire.ps1
@@ -14,7 +14,6 @@
 # limitations under the License.
 
 $ErrorActionPreference = "Stop"
-Import-Module Packer -Force
 
 mkdir C:\gemfire
 cd C:\gemfire
diff --git a/packer/windows/install-openssl.ps1 b/packer/windows/install-openssl.ps1
new file mode 100644
index 0000000..ef69b6f
--- /dev/null
+++ b/packer/windows/install-openssl.ps1
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+# 
+#      http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+$ErrorActionPreference = "Stop"
+Import-Module Packer -Force
+
+Install-Package https://slproweb.com/download/Win64OpenSSL-1_1_1b.exe -ArgumentList /silent
diff --git a/templates/security/CMakeLists.txt b/templates/security/CMakeLists.txt
index b20760e..0bf308e 100644
--- a/templates/security/CMakeLists.txt
+++ b/templates/security/CMakeLists.txt
@@ -41,6 +41,7 @@
     apache-geode
     OpenSSL::Crypto
   PRIVATE
+    openssl-compat
     _WarningsAsError
 )
 
diff --git a/templates/security/PkcsAuthInit.cpp b/templates/security/PkcsAuthInit.cpp
index 7d81143..1150289 100644
--- a/templates/security/PkcsAuthInit.cpp
+++ b/templates/security/PkcsAuthInit.cpp
@@ -17,6 +17,8 @@
 
 #include "PkcsAuthInit.hpp"
 
+#include <openssl-compat.h>
+
 #include <cstdio>
 #include <string>
 
diff --git a/templates/security/PkcsAuthInit.hpp b/templates/security/PkcsAuthInit.hpp
index bc6ee17..5e3c94a 100644
--- a/templates/security/PkcsAuthInit.hpp
+++ b/templates/security/PkcsAuthInit.hpp
@@ -29,9 +29,8 @@
 #include <openssl/pem.h>
 #include <openssl/pkcs12.h>
 #include <openssl/rsa.h>
-#include <openssl/x509.h>
-#define KSSL_H 1
 #include <openssl/ssl.h>
+#include <openssl/x509.h>
 
 #pragma error_messages(on, macroredef)
 
diff --git a/tests/cpp/security/CMakeLists.txt b/tests/cpp/security/CMakeLists.txt
index ce1b499..cee20a6 100644
--- a/tests/cpp/security/CMakeLists.txt
+++ b/tests/cpp/security/CMakeLists.txt
@@ -48,6 +48,7 @@
     OpenSSL::Crypto
     OpenSSL::SSL
   PRIVATE
+    openssl-compat
     ACE::ACE
     _WarningsAsError
 )
diff --git a/tests/cpp/security/PkcsAuthInit.cpp b/tests/cpp/security/PkcsAuthInit.cpp
index 82b296e..9f75914 100644
--- a/tests/cpp/security/PkcsAuthInit.cpp
+++ b/tests/cpp/security/PkcsAuthInit.cpp
@@ -17,6 +17,8 @@
 
 #include "PkcsAuthInit.hpp"
 
+#include <openssl-compat.h>
+
 #include <cstdio>
 #include <string>
 #include <util/Log.hpp>
diff --git a/tests/cpp/security/PkcsAuthInit.hpp b/tests/cpp/security/PkcsAuthInit.hpp
index 85e2183..3eb03da 100644
--- a/tests/cpp/security/PkcsAuthInit.hpp
+++ b/tests/cpp/security/PkcsAuthInit.hpp
@@ -31,9 +31,8 @@
 #include <openssl/pem.h>
 #include <openssl/pkcs12.h>
 #include <openssl/rsa.h>
-#include <openssl/x509.h>
-#define KSSL_H 1
 #include <openssl/ssl.h>
+#include <openssl/x509.h>
 
 #pragma error_messages(on, macroredef)