Skip to content

Commit 696239d

Browse files
authored
Link Windows crypto libs only when CPPHTTPLIB_OPENSSL_SUPPORT is set (yhirose#1254)
1 parent 6929d90 commit 696239d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

httplib.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ using ssize_t = int;
144144

145145
#include <io.h>
146146
#include <winsock2.h>
147-
148-
#include <wincrypt.h>
149147
#include <ws2tcpip.h>
150148

151149
#ifndef WSA_FLAG_NO_HANDLE_INHERIT
@@ -154,8 +152,6 @@ using ssize_t = int;
154152

155153
#ifdef _MSC_VER
156154
#pragma comment(lib, "ws2_32.lib")
157-
#pragma comment(lib, "crypt32.lib")
158-
#pragma comment(lib, "cryptui.lib")
159155
#endif
160156

161157
#ifndef strcasecmp
@@ -220,14 +216,20 @@ using socket_t = int;
220216
#include <thread>
221217

222218
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
223-
// these are defined in wincrypt.h and it breaks compilation if BoringSSL is
224-
// used
225219
#ifdef _WIN32
220+
#include <wincrypt.h>
221+
222+
// these are defined in wincrypt.h and it breaks compilation if BoringSSL is used
226223
#undef X509_NAME
227224
#undef X509_CERT_PAIR
228225
#undef X509_EXTENSIONS
229226
#undef PKCS7_SIGNER_INFO
227+
228+
#ifdef _MSC_VER
229+
#pragma comment(lib, "crypt32.lib")
230+
#pragma comment(lib, "cryptui.lib")
230231
#endif
232+
#endif //_WIN32
231233

232234
#include <openssl/err.h>
233235
#include <openssl/evp.h>

0 commit comments

Comments
 (0)