OpenSSL conflicts with wincrypt.h

Started by Juan José Santamaría Flechaover 4 years ago4 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t45496
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 03:21 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t45496_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t45496_1 && git checkout t45496_1

Patchset v1 (message #1) is on t45496_1

Jump to latest
#1Juan José Santamaría Flecha
juanjo.santamaria@gmail.com

Hello,

When building Postgres using MSVC with Kerberos Version 4.1 and OpenSSL
1.1.1l (both of them, using only one will raise no errors), I see errors
like:

"C:\postgres\pgsql.sln" (default target) (1) ->
"C:\postgres\postgres.vcxproj" (default target) (2) ->
(ClCompile target) ->
C:\postgres\src\backend\libpq\be-secure-openssl.c(583,43): warning C4047:
'function': 'X509_NAME *' differs in levels of indirection from 'int'
[C:\postgres\pos
tgres.vcxproj]

"C:\postgres\pgsql.sln" (default target) (1) ->
"C:\postgres\postgres.vcxproj" (default target) (2) ->
(ClCompile target) ->
C:\postgres\src\backend\libpq\be-secure-openssl.c(74,35): error C2143:
syntax error: missing ')' before '(' [C:\postgres\postgres.vcxproj]

There is a comment in 'src/backend/libpq/be-secure-openssl.c' addressing
this issue, but I have to explicitly undefine X509_NAME. Please find
attached a patch for so.

Regards,

Juan José Santamaría Flecha

Attachments:

t45496_1
0001-OpenSSL-conflicts-with-wincrypt.patchapplication/x-patch; name=0001-OpenSSL-conflicts-with-wincrypt.patchDownload+3-0
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Juan José Santamaría Flecha (#1)
Re: OpenSSL conflicts with wincrypt.h

=?UTF-8?Q?Juan_Jos=C3=A9_Santamar=C3=ADa_Flecha?= <juanjo.santamaria@gmail.com> writes:

There is a comment in 'src/backend/libpq/be-secure-openssl.c' addressing
this issue, but I have to explicitly undefine X509_NAME. Please find
attached a patch for so.

Um ... why? Shouldn't the #undef in the OpenSSL headers take care
of the problem?

regards, tom lane

#3Juan José Santamaría Flecha
juanjo.santamaria@gmail.com
In reply to: Tom Lane (#2)
Re: OpenSSL conflicts with wincrypt.h

On Fri, Feb 11, 2022 at 4:36 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

=?UTF-8?Q?Juan_Jos=C3=A9_Santamar=C3=ADa_Flecha?= <
juanjo.santamaria@gmail.com> writes:

There is a comment in 'src/backend/libpq/be-secure-openssl.c' addressing
this issue, but I have to explicitly undefine X509_NAME. Please find
attached a patch for so.

Um ... why? Shouldn't the #undef in the OpenSSL headers take care
of the problem?

After <openssl/ossl_typ.h> has been included, any inclusion of

<wincrypt.h> will be troublesome. There is already something similar in
'contrib/sslinfo/sslinfo.c'. This shouldn't be a problem while
defining WIN32_LEAN_AND_MEAN, but kerberos is directly including
<wincrypt.h> in <win-mac.h>.

Regards,

Juan José Santamaría Flecha

#4Daniel Gustafsson
daniel@yesql.se
In reply to: Juan José Santamaría Flecha (#3)
Re: OpenSSL conflicts with wincrypt.h

On 15 Feb 2022, at 14:12, Juan José Santamaría Flecha <juanjo.santamaria@gmail.com> wrote:

After <openssl/ossl_typ.h> has been included, any inclusion of <wincrypt.h> will be troublesome.

Not that it changes anything here, but FTR: in OpenSSL 3.0.0 and onwards this
undef has been moved to <openssl/types.h>

--
Daniel Gustafsson https://vmware.com/