Skip to content

windows: fix WinCrypt/OpenSSL conflict - #24036

Closed
vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:wincrypt-ossl-conflict-2026
Closed

vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:wincrypt-ossl-conflict-2026

Conversation

@vszakats

Copy link
Copy Markdown
Member

After recent changes to crypto/hash use, openssl headers can be included
earlier than before, earlier than the conflict mitigation previously put
into lib/vtls/openssl.h. This broke some build configurations.

Move the conflict mitigation as up to the global headers as possible to
make it effective again, hopefully fixing this for good.

Seen in curl-for-win dev builds with OpenSSL in win-llvm:

In file included from curl-for-win/curl/_x64-win-ucrt-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_4_c.c:22:
In file included from curl-for-win/curl/lib/vauth/digest.c:36:
In file included from curl-for-win/curl/lib/curl_sha512_256.h:41:
In file included from curl-for-win/awslc/_x64-win-ucrt/usr/include/openssl/opensslv.h:7:
In file included from curl-for-win/awslc/_x64-win-ucrt/usr/include/openssl/crypto.h:7:
curl-for-win/awslc/_x64-win-ucrt/usr/include/openssl/base.h:335:29: error: expected ')'
  335 | typedef struct X509_name_st X509_NAME;
      |                             ^
curl-for-win/llvm-mingw/x86_64-w64-mingw32/include/wincrypt.h:1515:29: note: expanded from macro 'X509_NAME'
 1515 | #define X509_NAME ((LPCSTR) 7)
      |                             ^

Ref: https://github.com/curl/curl-for-win/actions/runs/44300799917/job/134789709975#step:3:5085

Follow-up to ff18b24 #23497
Follow-up to f0f0a7f #21136

After recent changes to crypto/hash use, openssl headers can be included
earlier than before, earlier than the conflict mitigation previously put
into `lib/vtls/openssl.h`. This broke some build configurations.

Move the conflict mitigation as up to the global headers as possible to
make it effective again, hopefully fixing this for good.

Seen in curl-for-win dev builds with OpenSSL in win-llvm:
```
In file included from curl-for-win/curl/_x64-win-ucrt-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_4_c.c:22:
In file included from curl-for-win/curl/lib/vauth/digest.c:36:
In file included from curl-for-win/curl/lib/curl_sha512_256.h:41:
In file included from curl-for-win/awslc/_x64-win-ucrt/usr/include/openssl/opensslv.h:7:
In file included from curl-for-win/awslc/_x64-win-ucrt/usr/include/openssl/crypto.h:7:
curl-for-win/awslc/_x64-win-ucrt/usr/include/openssl/base.h:335:29: error: expected ')'
  335 | typedef struct X509_name_st X509_NAME;
      |                             ^
curl-for-win/llvm-mingw/x86_64-w64-mingw32/include/wincrypt.h:1515:29: note: expanded from macro 'X509_NAME'
 1515 | #define X509_NAME ((LPCSTR) 7)
      |                             ^
```
Ref: https://github.com/curl/curl-for-win/actions/runs/44300799917/job/134789709975#step:3:5085

Follow-up to ff18b24 curl#23497
Follow-up to f0f0a7f curl#21136
@vszakats
vszakats force-pushed the wincrypt-ossl-conflict-2026 branch from 42e866e to 6bfb123 Compare November 18, 2026 12:47
@vszakats

vszakats commented Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

MSYS2 package bumps happened, and it looks a 3rd-party header is
defining HAVE_UNISTD_H again:

D:/a/curl/curl/lib/dict.c(53): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory

https://github.com/curl/curl/actions/runs/44307325311/job/134812375233?pr=24036

edit: it's zlib, doing some changes that broke the previous workaround, and
now not only including unistd.h wrongly, but regressed to now also defining
HAVE_UNISTD_H in its public header, breaking other code that depends on
this. Sigh. edit: it isn't even using this macro, I'm puzzled.

PR → #24037

vszakats added a commit that referenced this pull request Nov 18, 2026
…ader

zlib 1.3.1.2+ built with cmake sets `HAVE_UNISTD_H` to `1` in its public
header when the zlib build environment detected `unistd.h`. This breaks
dependents that rely on this macro, when the zlib-build-time value differs
from the actual target build environment, as in curl CI, which uses the
mingw-built package in an MSVC build.

The issue surfaced when the MSYS2 package switched to using cmake
while bumping from 1.3.2 to 1.4, and this propagated into the Windows
runner, causing:
```
curl/lib/dict.c(58): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
```
Ref: https://github.com/curl/curl/actions/runs/44311921832/job/134828014535?pr=24037#step:11:35

Refs:
madler/zlib@3d6dc3c#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR39-R41
msys2/MINGW-packages@5cbcc05
msys2/MINGW-packages#33269

Bug: #24036 (comment)
Follow-up to c129d0b #17561

Closes #24037
@vszakats vszakats closed this in 13be3e5 Nov 18, 2026
@vszakats
vszakats deleted the wincrypt-ossl-conflict-2026 branch November 18, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant