openssl: Header file conflict code bug in windows

//reappear bug
#include <openssl/sha.h>
#include <openssl/aes.h>
#include <openssl/evp.h>
#ifndef CPPHTTPLIB_OPENSSL_SUPPORT
#define CPPHTTPLIB_OPENSSL_SUPPORT
#endif
#include <httplib.h>

the conflict between the above code and the httplib project reappear bug example

openssl github issue

httplib github issue

Previous discussion in qt bugreport

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 26 (19 by maintainers)

Commits related to this issue

Most upvoted comments

The httplib scenario that started this thread was directly including wincrypt.h - not windows.h, so WIN32_LEAN_AND_MEAN is not applicable.

I think that httplib is an untypical case, because it has a header-only implementation which is intended to be included into a single C-module. For a general purpose HTTP library, I would consider it bad style or at least lack of abstraction to include implementation-specific headers like wincrypt.h or the openssl header. If at all, it should use forward declarations.

If we are happy to say that wincrypt.h must always be included before any OpenSSL headers, then we can maybe close this issue with some documentation update instead.

As soon as two third party libraries include mixed Wincrypt and OpenSSL headers, then it’s impossible to follow that guide. But as I said, it’s the third party library headers that need to be fixed imho.

If there are applications that need (some of) the symbols in wincrypt.h and OpenSSL symbols, then I think the PR I have is a step in the right direction.

It may help, or maybe not. I’m not sure whether it will work in all constellations. In any case, I am opposed to the name WINCRYPT_OPENSSL_SYMBOL_COMPAT, it should be a more generic name like WINCRYPT_[USE_]SYMBOL_NAMESPACE or something like that. You can mention OpenSSL as an example in the preceding comment, but please don’t make it part of the #define’s name.

The short term solution seems like a reasonable approach. At least for now. I’m not sure if that would qualify as a bug fix eligible for backport to 3.0/1.1.1 (we normally try to avoid messing with the header files in a stable release)…I’m trying to think if there is any situation where doing that could break something

(2) sounds ideal if it can be arranged…but probably doesn’t help for quite a long time down the road when everyone has the new version of wincrypt.h.

In general going forward it would be great to have reasonable prefixes on both sides to minimize the likelihood of conflict.

Yes. From OpenSSL’s side we are trying to move to using the OSSL_ prefix for all new features - but we don’t do that if we’re just adding new things into a namespace we’ve already “claimed”. So, for example, new functions for doing X509 related things will start with X509_. Moving away from doing that would be very disruptive unfortunately 😦