Skip to content

Commit 1241fcb

Browse files
committed
Second attempt to silence SSL compile failures on hamerkop.
After further investigation, it seems the cause of the problem is our recent decision to start defining WIN32_LEAN_AND_MEAN. That causes <windows.h> to no longer include <wincrypt.h>, which means that the OpenSSL headers are unable to prevent conflicts with that header by #undef'ing the conflicting macros. Apparently, some other system header that be-secure-openssl.c #includes after the OpenSSL headers is pulling in <wincrypt.h>. It's obscure just where that happens and why we're not seeing it on other Windows buildfarm animals. However, it should work to move the OpenSSL #includes to the end of the list. For the sake of future-proofing, do likewise in fe-secure-openssl.c. In passing, remove useless double inclusions of <openssl/ssl.h>. Thanks to Thomas Munro for running down the relevant information. Discussion: https://postgr.es/m/1051867.1635720347@sss.pgh.pa.us
1 parent 05e6e78 commit 1241fcb

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/backend/libpq/be-secure-openssl.c

+15-9
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@
2929
#include <arpa/inet.h>
3030
#endif
3131

32-
#include <openssl/ssl.h>
33-
#include <openssl/conf.h>
34-
#include <openssl/dh.h>
35-
#ifndef OPENSSL_NO_ECDH
36-
#include <openssl/ec.h>
37-
#endif
38-
#include <openssl/x509v3.h>
39-
40-
#include "common/openssl.h"
4132
#include "libpq/libpq.h"
4233
#include "miscadmin.h"
4334
#include "pgstat.h"
@@ -46,6 +37,21 @@
4637
#include "tcop/tcopprot.h"
4738
#include "utils/memutils.h"
4839

40+
/*
41+
* These SSL-related #includes must come after all system-provided headers.
42+
* This ensures that OpenSSL can take care of conflicts with Windows'
43+
* <wincrypt.h> by #undef'ing the conflicting macros. (We don't directly
44+
* include <wincrypt.h>, but some other Windows headers do.)
45+
*/
46+
#include "common/openssl.h"
47+
#include <openssl/conf.h>
48+
#include <openssl/dh.h>
49+
#ifndef OPENSSL_NO_ECDH
50+
#include <openssl/ec.h>
51+
#endif
52+
#include <openssl/x509v3.h>
53+
54+
4955
/* default init hook can be overridden by a shared library */
5056
static void default_openssl_tls_init(SSL_CTX *context, bool isServerStart);
5157
openssl_tls_init_hook_typ openssl_tls_init_hook = default_openssl_tls_init;

src/interfaces/libpq/fe-secure-openssl.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "fe-auth.h"
3131
#include "fe-secure-common.h"
3232
#include "libpq-int.h"
33-
#include "common/openssl.h"
3433

3534
#ifdef WIN32
3635
#include "win32.h"
@@ -55,13 +54,20 @@
5554
#endif
5655
#endif
5756

58-
#include <openssl/ssl.h>
57+
/*
58+
* These SSL-related #includes must come after all system-provided headers.
59+
* This ensures that OpenSSL can take care of conflicts with Windows'
60+
* <wincrypt.h> by #undef'ing the conflicting macros. (We don't directly
61+
* include <wincrypt.h>, but some other Windows headers do.)
62+
*/
63+
#include "common/openssl.h"
5964
#include <openssl/conf.h>
6065
#ifdef USE_SSL_ENGINE
6166
#include <openssl/engine.h>
6267
#endif
6368
#include <openssl/x509v3.h>
6469

70+
6571
static int verify_cb(int ok, X509_STORE_CTX *ctx);
6672
static int openssl_verify_peer_name_matches_certificate_name(PGconn *conn,
6773
ASN1_STRING *name,

0 commit comments

Comments
 (0)