Skip to content

boringssl: fix more coexist cases with Schannel/WinCrypt - #21136

Closed
vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:bssl-schan-coexist-cont
Closed

vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:bssl-schan-coexist-cont

Conversation

@vszakats

@vszakats vszakats commented Mar 28, 2026 •

Copy link
Copy Markdown
Member

By moving the coexist workaround from vtls/openssl.c to vtls/openssl.h.
This way it also applies to vtls.c (and possibly other sources including
vtls/openssl.h), which may need it in unity builds before BoringSSL
header openssl/ssl.h pulling in the conflicting symbols and causing
conflicts otherwise.

Seen with build config:

-DCURL_USE_SCHANNEL=ON -DCURL_USE_OPENSSL=ON
-DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=30

Fixing:

In file included from _cm-win-boringssl/lib/CMakeFiles/libcurl_object.dir/Unity/unity_5_c.c:7:
In file included from lib/vtls/vtls.c:54:
In file included from lib/vtls/openssl.h:33:
In file included from /path/to/boringssl/_x64-win-ucrt/usr/include/openssl/opensslv.h:18:
In file included from /path/to/boringssl/_x64-win-ucrt/usr/include/openssl/crypto.h:18:
/path/to/boringssl/_x64-win-ucrt/usr/include/openssl/base.h:293:29: error: expected ')'
  293 | typedef struct X509_name_st X509_NAME;
      |                             ^
/path/to/llvm-mingw/x86_64-w64-mingw32/include/wincrypt.h:1515:29: note: expanded from macro 'X509_NAME'
 1515 | #define X509_NAME ((LPCSTR) 7)
      |                             ^
[...]

Ref: 2a92c39 #20567

By moving the coexist workaround from vtls/openssl.c to vtls/openssl.h.
This way it also applies to vtls.c (and possibly other sources including
`vtls/openssl.h`), which may need it before including BoringSSL header
`openssl/ssl.h` pulling in the conflicting symbols and causing conflicts
otherwise.

Example build:
```
-DCURL_USE_SCHANNEL=ON -DCURL_USE_OPENSSL=ON
-DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=30
```

Fixing:
```
In file included from _cm-win-boringssl/lib/CMakeFiles/libcurl_object.dir/Unity/unity_5_c.c:7:
In file included from lib/vtls/vtls.c:54:
In file included from lib/vtls/openssl.h:33:
In file included from /path/to/boringssl/_x64-win-ucrt/usr/include/openssl/opensslv.h:18:
In file included from /path/to/boringssl/_x64-win-ucrt/usr/include/openssl/crypto.h:18:
/path/to/boringssl/_x64-win-ucrt/usr/include/openssl/base.h:293:29: error: expected ')'
  293 | typedef struct X509_name_st X509_NAME;
      |                             ^
/path/to/llvm-mingw/x86_64-w64-mingw32/include/wincrypt.h:1515:29: note: expanded from macro 'X509_NAME'
 1515 | #define X509_NAME ((LPCSTR) 7)
      |                             ^
```

Ref: 2a92c39 curl#20567
@vszakats vszakats added build TLS Windows Windows-specific labels Mar 28, 2026
@vszakats vszakats closed this in f0f0a7f Mar 28, 2026
@vszakats
vszakats deleted the bssl-schan-coexist-cont branch March 28, 2026 14:54
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
By moving the coexist workaround from vtls/openssl.c to vtls/openssl.h.
This way it also applies to vtls.c (and possibly other sources including
`vtls/openssl.h`), which may need it in unity builds before BoringSSL
header `openssl/ssl.h` pulling in the conflicting symbols and causing
conflicts otherwise.

Seen with build config:
```
-DCURL_USE_SCHANNEL=ON -DCURL_USE_OPENSSL=ON
-DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=30
```

Fixing:
```
In file included from _cm-win-boringssl/lib/CMakeFiles/libcurl_object.dir/Unity/unity_5_c.c:7:
In file included from lib/vtls/vtls.c:54:
In file included from lib/vtls/openssl.h:33:
In file included from /path/to/boringssl/_x64-win-ucrt/usr/include/openssl/opensslv.h:18:
In file included from /path/to/boringssl/_x64-win-ucrt/usr/include/openssl/crypto.h:18:
/path/to/boringssl/_x64-win-ucrt/usr/include/openssl/base.h:293:29: error: expected ')'
  293 | typedef struct X509_name_st X509_NAME;
      |                             ^
/path/to/llvm-mingw/x86_64-w64-mingw32/include/wincrypt.h:1515:29: note: expanded from macro 'X509_NAME'
 1515 | #define X509_NAME ((LPCSTR) 7)
      |                             ^
[...]
```

Ref: 2a92c39 curl#20567

Closes curl#21136
vszakats added a commit to vszakats/curl that referenced this pull request Nov 18, 2026
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 added a commit that referenced this pull request Nov 18, 2026
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

Closes #24036
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build TLS Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

1 participant