eidheim / Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
MIT License
2.62k stars 758 forks source link

rc 3.0.0 examples wont build if openssl is detected due to invalid const void* to void* conversion in crypto.hpp #150

Closed Jester3141 closed 6 years ago

Jester3141 commented 7 years ago

The latest release candidate examples wont build when openssl is detected due to a invalid conversion in crypto.hpp.

This would likely affect any program including crypto.hpp.

The following is from my compile log...

In file included from eidheim/http_examples.cpp:15:0:
eidheim/crypto.hpp: In static member function 'static std::string SimpleWeb::Crypto::Base64::decode(const string&)':
eidheim/crypto.hpp:72:74: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
         bio = BIO_new_mem_buf(&base64[0], static_cast<int>(base64.size()));
                                                                          ^
In file included from /usr/include/openssl/evp.h:75:0,
                 from eidheim/crypto.hpp:13,
                 from eidheim/http_examples.cpp:15:
/usr/include/openssl/bio.h:672:6: error:   initializing argument 1 of 'BIO* BIO_new_mem_buf(void*, int)' [-fpermissive]
 BIO *BIO_new_mem_buf(void *buf, int len);

I am running Centos 7.3. gcc version 4.8.5

eidheim commented 7 years ago

Thank you, but my BIO_new_mem_buf declaration looks like this: BIO *BIO_new_mem_buf(const void *buf, int len); Are you sure you are using OpenSSL, and not BoringSSL or LibreSSL? I think I remember that BoringSSL had wrong BIO_new_mem_buf declaration at some time.

Digicrat commented 7 years ago

Same issue here when trying to build on an older Ubuntu release with OpenSSL 1.01f-1ubuntu2.22. Looking at the history of the OpenSSL project it looks like the 'const' flag was added to this parameter in a more recent release.

This is therefore not a bug with the project, but an incompatibility with older distributions.

As a workaround for anybody else that hits this issue, either update OpenSSL, or if you don't care about HTTPS (ie: for local experimentation like I'm currently doing), just comment out in CMakeFiles.txt any reference to OpenSSL (two 'if' conditions+contents and the find_package call).

eidheim commented 6 years ago

I added a workaround for this problem in https://github.com/eidheim/Simple-Web-Server/commit/702a571451899f903660aa33835cc279051c0b0e