openssl: Fix compilation on Windows when ngtcp2 is enabled#5606
Closed
jblazquez wants to merge 1 commit intocurl:masterfrom
jblazquez:patch-1
Closed
openssl: Fix compilation on Windows when ngtcp2 is enabled#5606jblazquez wants to merge 1 commit intocurl:masterfrom jblazquez:patch-1
jblazquez wants to merge 1 commit intocurl:masterfrom
jblazquez:patch-1
Conversation
The `wincrypt.h` Windows header defines a number of preprocessor macros that conflict with identically named OpenSSL types. For example, it defines the following macros: ``` #define X509_NAME ((LPCSTR) 7) #define OCSP_REQUEST ((LPCSTR) 66) #define OCSP_RESPONSE ((LPCSTR) 67) ``` Which conflict with these OpenSSL types and cause compile errors: ``` typedef struct X509_name_st X509_NAME; typedef struct ocsp_request_st OCSP_REQUEST; typedef struct ocsp_response_st OCSP_RESPONSE; ``` OpenSSL headers already try to avoid these conflicts by [undefining these Windows macros](https://github.com/openssl/openssl/blob/15dfa0/include/openssl/types.h#L71-L78). However, that requires that `wincrypt.h` is included _before_ any OpenSSL header. In curl's `vtls/openssl.c` file, there is at least one configuration where an OpenSSL header is included before `wincrypt.h`. If `ngtcp2` is enabled, for example, then the `urldata.h` include ends up including OpenSSL headers transitively like this: ``` Note: including file: urldata.h Note: including file: quic.h Note: including file: vquic/ngtcp2.h Note: including file: openssl/ssl.h ``` That include happens [here](https://github.com/curl/curl/blob/14c17a/lib/vquic/ngtcp2.h#L32). In order to solve these conflicts and fix the compile issues when `ngtcp2` is enabled, we need to move the `wincrypt.h` include as early as possible.
Member
|
Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
wincrypt.hWindows header defines a number of preprocessor macros that conflict with identically named OpenSSL types. For example, it defines the following macros:Which conflict with these OpenSSL types and cause compile errors:
OpenSSL headers already try to avoid these conflicts by undefining these Windows macros. However, that requires that
wincrypt.his included before any OpenSSL header.In curl's
vtls/openssl.cfile, there is at least one configuration where an OpenSSL header is included beforewincrypt.h. Ifngtcp2is enabled, for example, then theurldata.hinclude ends up including OpenSSL headers transitively like this:That include happens here.
In order to solve these conflicts and fix the compile issues when
ngtcp2is enabled, we need to move thewincrypt.hinclude as early as possible.