jmccl/acme-lw

Does not compile

Closed this issue · 5 comments

Hello,
maybe I am doing something wrong, but it does not compile on my CentOS7 OS
Create makefiles worked by typing "cmake3 ." (just "cmake" is an old 2.x version on CentOS7)

But then I get so many compile errors, don't know where I should begin...
First, "sting-Literals" did not work, so I cheanges "..."s just to "..." and this error did not came up again.
But after that there are still many errors (I post the errors at the end).

Originaly there is an old GCC compiler availave on CentOS7: 4.8.5
But I installd scl7 (devtoolset-7) and tried id again with GCC 7.3.1 - still the same...
And again with devtoolset-8 -> GCC 8.3.1 - still the same...

This is the build output:

Scanning dependencies of target acme_lw
[ 16%] Building CXX object lib/CMakeFiles/acme_lw.dir/__/internal/http.cpp.o
[ 33%] Building CXX object lib/CMakeFiles/acme_lw.dir/acme-exception.cpp.o
[ 50%] Building CXX object lib/CMakeFiles/acme_lw.dir/acme-lw.cpp.o
In file included from /home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:14:0:
/home/hansdampf/workspace_acme/acme-lw/lib/../internal/json.hpp: In Elementfunktion »nlohmann::json_pointer& nlohmann::json_pointer::operator/=(std::size_t)«:
/home/hansdampf/workspace_acme/acme-lw/lib/../internal/json.hpp:10217:5: Fehler: Deklaration von »array_index« überdeckt ein Element von 'this' [-Werror=shadow]
{
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In Konstruktor »{anonymous}::Ptr<TYPE, FREE>::Ptr(TYPE*)«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:57:83: Fehler: ungültige Operanden der Typen »const char [18]« und »const char*« für binäres »operator+«
throw acme_lw::AcmeException("Failed to create " + typeid(this).name());
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In Elementfunktion »{anonymous}::Ptr<TYPE, FREE>& {anonymous}::Ptr<TYPE, FREE>::operator=({anonymous}::Ptr<TYPE, FREE>&&)«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:73:83: Fehler: ungültige Operanden der Typen »const char [18]« und »const char
« für binäres »operator+«
throw acme_lw::AcmeException("Failed to create " + typeid(this).name());
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: Im globalen Gültigkeitsbereich:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:104:25: Fehler: »EVP_MD_CTX_free« wurde in diesem Gültigkeitsbereich nicht definiert
typedef Ptr<EVP_MD_CTX, EVP_MD_CTX_free> EVP_MD_CTXptr;
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:104:40: Fehler: Templateargument 2 ist ungültig
typedef Ptr<EVP_MD_CTX, EVP_MD_CTX_free> EVP_MD_CTXptr;
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:104:78: Fehler: invalid type in declaration before »;« token
typedef Ptr<EVP_MD_CTX, EVP_MD_CTX_free> EVP_MD_CTXptr;
^
In file included from /usr/include/openssl/objects.h:965:0,
from /usr/include/openssl/evp.h:94,
from /home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:16:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In Funktion »std::pair<std::basic_string, std::basic_string > {anonymous}::makeCertificateSigningRequest(const std::list<std::basic_string >&)«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:269:122: Fehler: ungültige Umwandlung von »const char
« in »char*« [-fpermissive]
if (!sk_X509_EXTENSION_push(extensions, X509V3_EXT_conf_nid(nullptr, nullptr, NID_subject_alt_name, value.c_str())))
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In Funktion »T {anonymous}::extractExpiryData(const acme_lw::Certificate&, const std::function<T(const asn1_string_st
)>&)«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:349:45: Fehler: es gibt keine Argumente für »X509_getm_notAfter«, die von einem Templateparameter abhängen, weshalb eine Deklaration von »X509_getm_notAfter« verfügbar sein muss [-fpermissive]
ASN1_TIME * t = X509_getm_notAfter(x509);
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:349:45: Anmerkung: (mit »-fpermissive« wird G++ den Code akzeptieren, aber die Verwendung eines nicht deklarierten Namens ist veraltet)
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In Konstruktor »acme_lw::AcmeClientImpl::AcmeClientImpl(const string&)«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:383:37: Fehler: »RSA_get0_key« wurde in diesem Gültigkeitsbereich nicht definiert
RSA_get0_key(rsa, &n, &e, &d);
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In Elementfunktion »std::string acme_lw::AcmeClientImpl::sign(const string&)«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:416:49: Fehler: ungültige Umwandlung von »EVP_MD_CTX
{aka env_md_ctx_st*}« in »{anonymous}::EVP_MD_CTXptr {aka int}« [-fpermissive]
EVP_MD_CTXptr context(EVP_MD_CTX_create());
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:419:32: Fehler: ungültiger Argumenttyp in unärem »« (haben »{anonymous}::EVP_MD_CTXptr {aka int}«)
EVP_DigestInit_ex(context, sha256, nullptr) != 1 ||
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:420:33: Fehler: ungültiger Argumenttyp in unärem »
« (haben »{anonymous}::EVP_MD_CTXptr {aka int}«)
EVP_DigestSignInit(context, nullptr, sha256, nullptr, privateKey_) != 1 ||
^
In file included from /home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:16:0:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:421:35: Fehler: ungültiger Argumenttyp in unärem »
« (haben »{anonymous}::EVP_MD_CTXptr {aka int}«)
EVP_DigestSignUpdate(context, s.c_str(), s.size()) != 1 ||
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:422:34: Fehler: ungültiger Argumenttyp in unärem »
« (haben »{anonymous}::EVP_MD_CTXptr {aka int}«)
EVP_DigestSignFinal(context, nullptr, &signatureLength) != 1)
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:428:34: Fehler: ungültiger Argumenttyp in unärem »
« (haben »{anonymous}::EVP_MD_CTXptr {aka int}«)
if (EVP_DigestSignFinal(context, &signature.front(), &signatureLength) != 1)
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In Elementfunktion »T acme_lw::AcmeClientImpl::sendRequest(const string&, const string&, std::pair<std::basic_string, std::basic_string >
)«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:450:25: Fehler: ungültige Operanden der Typen »const char [2]« und »const char [15]« für binäres »operator+«
u8R"("protected": ")" + protectd + ""," +
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In statischer Elementfunktion »static void acme_lw::AcmeClient::init()«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:631:70: Fehler: ungültige Operanden der Typen »const char [37]« und »const char
« für binäres »operator+«
throw AcmeException("Unable to initialize endpoints from " + directoryUrl + ": " + e.what());
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In Instanziierung von »T {anonymous}::extractExpiryData(const acme_lw::Certificate&, const std::function<T(const asn1_string_st
)>&) [with T = long int]«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:670:10: von hier erfordert
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:349:45: Fehler: »X509_getm_notAfter« wurde in diesem Gültigkeitsbereich nicht definiert
ASN1_TIME * t = X509_getm_notAfter(x509);
^
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp: In Instanziierung von »T {anonymous}::extractExpiryData(const acme_lw::Certificate&, const std::function<T(const asn1_string_st
)>&) [with T = std::basic_string]«:
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:684:10: von hier erfordert
/home/hansdampf/workspace_acme/acme-lw/lib/acme-lw.cpp:349:45: Fehler: »X509_getm_notAfter« wurde in diesem Gültigkeitsbereich nicht definiert
cc1plus: Alle Warnungen werden als Fehler behandelt
make[2]: *** [lib/CMakeFiles/acme_lw.dir/build.make:109: lib/CMakeFiles/acme_lw.dir/acme-lw.cpp.o] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:135: lib/CMakeFiles/acme_lw.dir/all] Fehler 2
make: *** [Makefile:150: all] Fehler 2

jmccl commented

Thanks for putting the issue in.

I spent some time looking at this and my current inclination is to close it as “won’t fix.” I’ll explain what’s going on.

The code needs a compiler which supports C++14, which gcc 7 forward does, so that’s not an issue if you use that compiler rather than the OS default (As an aside, you wouldn’t want to remove the ‘s’ in ‘...’s for the string literals. That will change it from string concatenation to pointer addition and although it may compile it will crash when it runs.)

Assuming gcc 7+ is in use all the errors are due to CentOS 7 using OpenSSL 1.0.2k. OpenSSL 1.0 has been unsupported by the openssl team for a couple of years. RedHat supports it for the purpose of supporting the maintenance window for RHEL/CentOS 7.

Nonetheless, I was able to make it compile pretty easily with the installed 1.0 version (with some use of ‘ifdef’) but running it results in OpenSSL errors. I’m not sure what’s going on but some quick googling resulted in this thread and this link, which may be the source of the errors. I haven’t dug in more once I found the issue in the links.

reddit thread
blog post

My impression is any attempt to make Let’s Encrypt work with OpenSSL 1.0 is not going to be trivial, either with my code or potentially anything else.

If you disagree let me know why, but at the moment I’m taking the view that any distribution using OpenSSL 1.0 has been eclipsed by events.

Thank you so much for checking this issue so fast. Maybe I mixed and increased the problem by removing the string literals and trying to use a newer gcc version after that.
I will try it again (on weekend) by using your original source code and directly a new GCC version.
For now I would say let's close the ticket. You spent some time on trying to reproduce the error but this head-code compiles on your system. So first I will spend some time on my site. I would be really very cool if it works, because I could use it so much in my project.
Thanks so far.

jmccl commented

If you really want to make this work on CentOS I'd probably do a openssl 1.1 local build and use that for this project.

Good luck.

I was able to build it on CentOS7. OpenSSL 1.1 was really needed. There is a RPM available for RHEL7/CentOS7 (yum install openssl11 / openssl11-devel), but without a cmake 'find' module for this version. So there was some handwork necessary, but now there is a working exectuable without changing anything at your code.
Thank you so much again.

jmccl commented

That's great. I'm glad you were able get it working. Thanks for letting me know.