pocoproject / poco

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
https://pocoproject.org
Other
8.41k stars 2.16k forks source link

Poco C++ Static Library (Crypto and SSL) Linker Error on OS-X #790

Closed AbhinavBansal closed 5 years ago

AbhinavBansal commented 9 years ago

I have compiled Poco as static library to be used in an XCode6.1.1 Project for a mac application. However I see linking error for libraries: libPocoCrypto.a and libPocoNetSSL.a:

I have already verified that these libraries are built for x86_64 architecture.

Linker Error:

Undefined symbols for architecture x86_64: "_ASN1_STRING_data", referenced from: Poco::Crypto::X509Certificate::extractNames(std::1::basic_string, std::1::allocator >&, std::1::set, std::1::allocator >, std::1::less, std::1::allocator > >, std::1::allocator, std::__1::allocator > > >&) const in libPocoCryptod.a(X509Certificate.o) "_ASN1_STRING_length", referenced from: Poco::Crypto::X509Certificate::extractNames(std::1::basic_string, std::1::allocator >&, std::1::set, std::1::allocator >, std::1::less, std::1::allocator > >, std::1::allocator, std::1::allocator > > >&) const in libPocoCryptod.a(X509Certificate.o) "_BIO_ctrl", referenced from: Poco::Crypto::X509Certificate::load(std::1::basic_string, std::__1::allocator > const&) in libPocoCryptod.a(X509Certificate.o) ....

aleks-f commented 9 years ago

resolved at Stack Overflow, must link with libssl and libcrypto

AttitudeMonger commented 8 years ago

Hi, I ran

./configure --static --omit=Data/ODBC,Data/MySQL --config=Darwin32

And then I just ran make It built fine, but when I am trying to link the static libs in my project, I am getting this error message:

Undefined symbols for architecture i386:

"_CRYPTO_set_dynlock_create_callback", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in libPocoCrypto.a(OpenSSLInitializer.o)
  "_CRYPTO_set_dynlock_destroy_callback", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in libPocoCrypto.a(OpenSSLInitializer.o)
  "_CRYPTO_set_dynlock_lock_callback", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in libPocoCrypto.a(OpenSSLInitializer.o)
"_SSL_CTX_ctrl", referenced from:
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::createSSLContext() in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::addChainCertificate(Poco::Crypto::X509Certificate const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::enableSessionCache(bool) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::enableSessionCache(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::sessionCacheEnabled() const in libPocoNetSSL.a(Context.o)
      ...
  "_SSL_CTX_flush_sessions", referenced from:
      Poco::Net::Context::flushSessionCache() in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_free", referenced from:
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::~Context() in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_get_timeout", referenced from:
      Poco::Net::Context::getSessionTimeout() const in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_load_verify_locations", referenced from:
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_new", referenced from:
      Poco::Net::Context::createSSLContext() in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_set_cipher_list", referenced from:
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_set_default_passwd_cb", referenced from:
      Poco::Net::Context::createSSLContext() in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_set_default_verify_paths", referenced from:
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_set_session_id_context", referenced from:
      Poco::Net::Context::enableSessionCache(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_set_timeout", referenced from:
      Poco::Net::Context::setSessionTimeout(long) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_set_verify", referenced from:
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_set_verify_depth", referenced from:
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_use_PrivateKey_file", referenced from:
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_use_RSAPrivateKey", referenced from:
      Poco::Net::Context::usePrivateKey(Poco::Crypto::RSAKey const&) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_use_certificate", referenced from:
      Poco::Net::Context::useCertificate(Poco::Crypto::X509Certificate const&) in libPocoNetSSL.a(Context.o)
  "_SSL_CTX_use_certificate_chain_file", referenced from:
      Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(Context.o)
  "_SSL_SESSION_free", referenced from:
      Poco::Net::SecureSocketImpl::currentSession() in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::Session::~Session() in libPocoNetSSL.a(Session.o)
      Poco::Net::Session::~Session() in libPocoNetSSL.a(Session.o)
      Poco::Net::Session::~Session() in libPocoNetSSL.a(Session.o)
  "_SSL_connect", referenced from:
      Poco::Net::SecureSocketImpl::connectSSL(bool) in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_ctrl", referenced from:
      Poco::Net::SecureSocketImpl::connectSSL(bool) in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::SecureSocketImpl::sessionWasReused() in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_do_handshake", referenced from:
      Poco::Net::SecureSocketImpl::completeHandshake() in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_free", referenced from:
      Poco::Net::SecureSocketImpl::~SecureSocketImpl() in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::SecureSocketImpl::reset() in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::SecureSocketImpl::connect(Poco::Net::SocketAddress const&, bool) in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::SecureSocketImpl::connectSSL(bool) in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::SecureSocketImpl::connect(Poco::Net::SocketAddress const&, Poco::Timespan const&, bool) in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::SecureSocketImpl::connectNB(Poco::Net::SocketAddress const&) in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_get1_session", referenced from:
      Poco::Net::SecureSocketImpl::currentSession() in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_get_error", referenced from:
      Poco::Net::SecureSocketImpl::handleError(int) in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_get_peer_certificate", referenced from:
      Poco::Net::SecureSocketImpl::verifyPeerCertificateImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::SecureSocketImpl::peerCertificate() const in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_get_shutdown", referenced from:
      Poco::Net::SecureSocketImpl::shutdown() in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_library_init", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in libPocoCrypto.a(OpenSSLInitializer.o)
  "_SSL_load_error_strings", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in libPocoCrypto.a(OpenSSLInitializer.o)
  "_SSL_new", referenced from:
      Poco::Net::SecureSocketImpl::acceptSSL() in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::SecureSocketImpl::connectSSL(bool) in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_pending", referenced from:
      Poco::Net::SecureSocketImpl::available() const in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_read", referenced from:
      Poco::Net::SecureSocketImpl::receiveBytes(void*, int, int) in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_set_accept_state", referenced from:
      Poco::Net::SecureSocketImpl::acceptSSL() in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_set_bio", referenced from:
      Poco::Net::SecureSocketImpl::acceptSSL() in libPocoNetSSL.a(SecureSocketImpl.o)
      Poco::Net::SecureSocketImpl::connectSSL(bool) in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_set_connect_state", referenced from:
      Poco::Net::SecureSocketImpl::connectSSL(bool) in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_set_session", referenced from:
      Poco::Net::SecureSocketImpl::connectSSL(bool) in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_shutdown", referenced from:
      Poco::Net::SecureSocketImpl::shutdown() in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSL_write", referenced from:
      Poco::Net::SecureSocketImpl::sendBytes(void const*, int, int) in libPocoNetSSL.a(SecureSocketImpl.o)
  "_SSLv23_client_method", referenced from:
      Poco::Net::Context::createSSLContext() in libPocoNetSSL.a(Context.o)
  "_SSLv23_server_method", referenced from:
      Poco::Net::Context::createSSLContext() in libPocoNetSSL.a(Context.o)
  "_TLSv1_client_method", referenced from:
      Poco::Net::Context::createSSLContext() in libPocoNetSSL.a(Context.o)
  "_TLSv1_server_method", referenced from:
      Poco::Net::Context::createSSLContext() in libPocoNetSSL.a(Context.o)

This is happening only when I am linking the libraries built from the full Poco package. With the original one (which does not include NetSSL), it was building fine but causing linking problem due to libz, which then I removed as discussed, and that solved the problem of linking.

Any idea how to fix this issue? As per the discussion at http://stackoverflow.com/questions/29816076/poco-c-static-library-crypto-and-ssl-linker-error-on-os-x, I changed the link order of the libs as you mentioned, and even linked libcrypto.a and libssl.a as well. Same result. The error is introduced on the following line of code:

HTTPSClientSession *httpsSession = new HTTPSClientSession("https://securehost.com");

AbhinavBansal commented 8 years ago

It is not very evident from the documentation, but you need to build OpenSSL library statically and rebuild POCO with the statically built openssl. Then you also need to link openssl libraries in your xcode project to make it work.

AttitudeMonger commented 8 years ago

Yes, I have built it for 32 bit architecture and in the process of linking it. Didn't find it anywhere in the documentation. Do I need to include OpenSSL headers as well?

AttitudeMonger commented 8 years ago

What do you mean by 'rebuild POCO with statically built OpenSSL'? How do I do that?

AttitudeMonger commented 8 years ago

I built 32 bit OpenSSL on OS X and linked them statically. Same result. Link order, as mentioned by Alex in the SO comment, with crypto and ssl first.

AbhinavBansal commented 8 years ago

Are you sure your machine is 32 bit? It should probably be 64 bit.

Build poco as follows:

./configure --static --no-tests --no-samples --omit=Data/ODBC,Data/MySQL,Data/MongoDB --include-path=$OPENSSL_INCLUDE_PATH

AttitudeMonger commented 8 years ago

No my machine is 64 bit, I mention 32 bit option during my config statement as follows:

./configure --static --omit=Data/ODBC,Data/MySQL --config=Darwin32

Even after linking the 32 bit versions of SSL and Crypto I am getting error like

Undefined reference:
"_EVP_seed_cbc", referenced from:
      _SSL_library_init in libssl.a(ssl_algs.o)

Whereas a simple nm on the crypto library I built and am linking clearly shows the symbol to be there.

AbhinavBansal commented 8 years ago

So if your machine is 64 bit, why are you compiling in 32 bit mode?

AttitudeMonger commented 8 years ago

My application is 32 bit.

aleks-f commented 8 years ago

There's a bug in Darwin32, it's pointing to 64 bit

AttitudeMonger commented 8 years ago

Oh, okay. Any idea how to fix this? Looks like every time I start using Poco, I find a bug. Last time I did, I found a bug regarding building Poco statically on OS X. And now this.. :)

aleks-f commented 8 years ago

It's easy to fix:

./configure --static --omit=Data/ODBC,Data/MySQL --config=Darwin32-clang
AttitudeMonger commented 8 years ago

Oh okay. I looked at the Darwin32 Config file and saw it is already using clang, so was wondering what to do. Trying this...

AttitudeMonger commented 8 years ago

Hi Alex, I am still getting the same errors as before. I built it with the new new config option as you mentioned. Again, it build fine, but the error comes up during linking with my project and trying to use HTTPSClientSession.

AttitudeMonger commented 8 years ago

This is my linking order:

    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lcrypto
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lssl
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoNetSSL
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoCrypto
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoNet
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoZip
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoUtil
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoXML
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoJSON
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoFoundation

I built OpenSSL for 32 bit and linked them here (the default ones in my Mac are 64 bit).

AttitudeMonger commented 8 years ago

I thought may be it is still trying to include the System OpenSSL headers instead of the ones with which I compiled the 32 bit libs that I am linking, so I change the config command to

./configure --static --no-tests --no-samples --omit=Data/ODBC,Data/MySQL,Data/MongoDB --include-path=/Users/kausta/Desktop/openssl/openssl-1.0.0a/include --config=Darwin32-clang

(Although the headers in the OpenSSL include path are all symlinks to headers elsewhere, dunno whether that can be source of any problem.)

While making, I got couple of errors, which I had to fix, like changing TLSv1_1_client_method to TLSv1_client_method and TLSv1_1_server_method to TLSv1_server_method, both in OpenSSL/src/Context.cpp. These errors were probably because the method signatures were like that in the older headers. However, even though it built fine, I am getting the same errors while linking with my project and using HTTPSClientSession.

zosrothko commented 8 years ago

"While making, I got couple of errors, which I had to fix, like changing TLSv1_1_client_method to TLSv1_client_method and TLSv1_1_server_method to TLSv1_server_method, both in OpenSSL/src/Context.cpp. "... IMO, your poco@develop branch is behind the pocoproject/poco@develop branch because this has already been fixed.

obiltschnig commented 8 years ago

In your linking order you should put -lcrypto and -lssl behind -lPocoNetSSL and -lPocoCrypto. Furthermore, make sure you have a suitable version of OpenSSL built. With El Capitan, Apple no longer ships the OpenSSL headers (but still the shared libraries), so you need to build your own OpenSSL libraries. Or use the ones from brew, which also work. Furthermore, replacing TLSv1_1_client_method() with TLSv1_client_method() is not the way to go. Make sure your OpenSSL headers match your libraries.

AttitudeMonger commented 8 years ago

@zosrothko , I downloaded the package from the official source: http://pocoproject.org/download/index.html the complete edition. Is that behind the develop branch?

@obiltschnig , yes, plus it is 64 bit version. That's why I built OpenSSL afresh for 32 bit as per this link - http://stackoverflow.com/questions/4084210/how-do-i-build-openssl-as-32-bit-i386-on-mac-os-x, and linked the static libs obtained from there.

Without specifying the include path as I said in my last comment, it was building fine. But when I specify the include path to point to the OpenSSL download which I compiled for 32 bit (which I should do, since it makes sense to include the headers whose corresponding source I am building against), I was getting those two errors.

AttitudeMonger commented 8 years ago

@obiltschnig , I changed the link order to

    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoNetSSL
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoCrypto
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lcrypto
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lssl
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoNet
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoZip
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoUtil
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoXML
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoJSON
    LIBS += -L$$TOP_DEPSDIR/Poco/lib/mac/ -lPocoFoundation

Same result.

AttitudeMonger commented 8 years ago

@obiltschnig , I verified, in the <ssl.h> header which I downloaded, it is indeed TLSv1_client_method and not TLSv1_1_client_method, so the error was justified, because I was including the latest includes as well. Plus 1.0 is the latest version of OpenSSL as well.

obiltschnig commented 8 years ago

No, you have wrong headers. There is a TLSv1_1_client_method() (and TLSv1_2_client_method() for that matter) in current ssl.h.

zosrothko commented 8 years ago

You downloaded the poco-1.6.1 sources that do not compile/link with OpenSSL-1.0.0a. I was refering this fix before in for the poco-1.7.0 version which is the current development branch at GitHub here https://github.com/pocoproject/poco

@obiltschnig IMO, The OpenSSL-1.0.0a does not have the TLSv1_1_client_method() (and TLSv1_2_client_method(). Thoses methods have been introduced in a later version... That's why the fix is testing #if defined(SSL_OP_NO_TLSv1_1) && !defined(OPENSSL_NO_TLS1)

The define SSL_OP_NO_TLSv1_1 is a flag that can be passed to some other SSL functions to turn off the TLSv1_1 support during a single execution, hence the "NO" in its name. Because those flags are only defined in OpenSSL versions that include the thing to turn off (at least if not disabled when compiling OpenSSL itself), using the very existence of the flag definition is a as a way to determine if the thing is included in the OpenSSL version where the copy of "ssl.h" was taken from.

AttitudeMonger commented 8 years ago

@obiltschnig , okay, can you point me where from can I download the latest build of OpenSSL then?

As per this site: https://www.openssl.org/source/, 1.0.0 was released a week back, and 1.1 yesterday. You mean to say I should use the version which was releases yesterday?

AttitudeMonger commented 8 years ago

Okay, I downloaded the one from https://github.com/openssl/openssl, and there the header seem to have the methods as you said, @obiltschnig . I am trying it now. Will poco 1.7 work with that, @zosrothko ? Its version number is 1.1.0-pre2-dev.

zosrothko commented 8 years ago

The fix in poco-1.7.0 of the develop branch make OpenSSL-1.0.0a working (it works on Fedora 17 & Fedora 22 at least)

AttitudeMonger commented 8 years ago

Okkay. I will try with Poco 1.7 and OpenSSL 1.0.0a then (the one which I originally downloaded, where I had to make those fixes to TLSv1_1 named methods). Wish me luck! :)

AttitudeMonger commented 8 years ago

Okay, it built successfully, but gave a warning finally:

1 warning generated.
** Building library (release) /Users/Cupidvogel /Desktop/Poco1.7/poco-develop/lib/Darwin/i386/libPocoPDF.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Users/Cupidvogel /Desktop/Poco1.7/poco-develop/PDF/obj/Darwin/i386/release_static/pnggccrd.o has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Users/Cupidvogel /Desktop/Poco1.7/poco-develop/PDF/obj/Darwin/i386/release_static/pngvcrd.o has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /Users/Cupidvogel /Desktop/Poco1.7/poco-develop/lib/Darwin/i386/libPocoPDF.a(pnggccrd.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /Users/Cupidvogel /Desktop/Poco1.7/poco-develop/lib/Darwin/i386/libPocoPDF.a(pngvcrd.o) has no symbols

Will this be causing any problem? I did not see this message while building 1.6.1..

AttitudeMonger commented 8 years ago

Sigh. Same error.

zosrothko commented 8 years ago

Could you try a test: Poco 1.7 and OpenSSL 1.0.0a in shared mode instead of static?

AttitudeMonger commented 8 years ago

Both in shared mode? Or build Poco statically as I have been doing, but then build OpenSSL for shared lib and link them dynamically in my project alongwith the static Poco libs?

zosrothko commented 8 years ago

I would say both in shared mode first

AttitudeMonger commented 8 years ago

Okay. Trying it..

zosrothko commented 8 years ago

Just to mention that poco-1.7.0 on Fedora does not compile/link in static mode by the below errors with [fandre@obelix Static]$ openssl version OpenSSL 1.0.1k-fips 8 Jan 2015 [fandre@obelix Static]$

\ Building executable (debug) /home/fandre/poco/Static/Crypto/testsuite/bin/Linux/x86_64/static/testrunnerd g++ -DPOCO_BUILD_HOST=obelix -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -g -static -o /home/fandre/poco/Static/Crypto/testsuite/bin/Linux/x86_64/static/testrunnerd /home/fandre/poco/Static/Crypto/testsuite/obj/Linux/x86_64/debug_static/CryptoTestSuite.o /home/fandre/poco/Static/Crypto/testsuite/obj/Linux/x86_64/debug_static/Driver.o /home/fandre/poco/Static/Crypto/testsuite/obj/Linux/x86_64/debug_static/CryptoTest.o /home/fandre/poco/Static/Crypto/testsuite/obj/Linux/x86_64/debug_static/DigestEngineTest.o /home/fandre/poco/Static/Crypto/testsuite/obj/Linux/x86_64/debug_static/RSATest.o -L/home/fandre/poco/Static/lib/Linux/x86_64 -lPocoCryptod -lPocoFoundationd -lCppUnitd -lpthread -ldl -lrt -lssl -lcrypto -lz -ldl /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/libcrypto.a(fips.o): dans la fonction « verify_checksums »: (.text+0x4d9): AVERTISSEMENT: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/libssl.a(kssl.o): dans la fonction « kssl_skip_confound »: (.text+0x22e): référence indéfinie vers « valid_cksumtype » /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/libssl.a(kssl.o): dans la fonction « kssl_skip_confound »: (.text+0x258): référence indéfinie vers « krb5_checksum_size » /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/libssl.a(kssl.o): dans la fonction « kssl_skip_confound »: (.text+0x29d): référence indéfinie vers « krb5_checksum_size » /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/libssl.a(kssl.o): dans la fonction « kssl_keytab_is_available »: (.text+0x98c): référence indéfinie vers « krb5_init_context » /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/libssl.a(kssl.o): dans la fonction « kssl_keytab_is_available »: (.text+0x9a8): référence indéfinie vers « krb5_kt_resolve » /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/libssl.a(kssl.o): dans la fonction « kssl_keytab_is_available »:

AttitudeMonger commented 8 years ago

I am also getting a truckload of errors while trying to build Poco without the --static option, i.e

./configure --no-tests --no-samples --omit=Data/ODBC,Data/MySQL,Data/MongoDB --include-path=/Users/Cupidvogel/Desktop/openssldyn/openssl-1.0.0a/include --config=Darwin32-clang

followed by make:

Cupidvogel@a67r46s69241~/Desktop/Poco1.7/pocodyn/poco-develop$ make -s
** Building shared library (debug) /Users/Cupidvogel/Desktop/Poco1.7/pocodyn/poco-develop/lib/Darwin/i386/libPocoCryptod.40.dylib
ld: warning: ld: warning: ignoring file /usr/local/opt/openssl//lib/libcrypto.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/opt/openssl//lib/libcrypto.dylibignoring file /usr/local/opt/openssl//lib/libssl.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/opt/openssl//lib/libssl.dylib

Undefined symbols for architecture i386:
  "_ASN1_STRING_data", referenced from:
      Poco::Crypto::X509Certificate::extractNames(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) const in X509Certificate.o
  "_ASN1_STRING_length", referenced from:
      Poco::Crypto::X509Certificate::extractNames(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) const in X509Certificate.o
  "_BIO_ctrl", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::X509Certificate::load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in X509Certificate.o
      Poco::Crypto::X509Certificate::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in X509Certificate.o
      Poco::Crypto::X509Certificate::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in X509Certificate.o
      ...
  "_BIO_free", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::X509Certificate::load(std::__1::basic_istream<char, std::__1::char_traits<char> >&) in X509Certificate.o
      Poco::Crypto::X509Certificate::load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in X509Certificate.o
      Poco::Crypto::X509Certificate::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in X509Certificate.o
      ...
  "_BIO_new", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::X509Certificate::load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in X509Certificate.o
      Poco::Crypto::X509Certificate::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in X509Certificate.o
      Poco::Crypto::X509Certificate::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in X509Certificate.o
  "_BIO_new_mem_buf", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::X509Certificate::load(std::__1::basic_istream<char, std::__1::char_traits<char> >&) in X509Certificate.o
  "_BIO_s_file", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::X509Certificate::load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in X509Certificate.o
      Poco::Crypto::X509Certificate::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in X509Certificate.o
  "_BIO_s_mem", referenced from:
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::X509Certificate::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in X509Certificate.o
  "_BN_bn2bin", referenced from:
      Poco::Crypto::RSAKeyImpl::convertToByteVec(bignum_st const*) in RSAKeyImpl.o
  "_BN_free", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(int, unsigned long) in RSAKeyImpl.o
  "_BN_new", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(int, unsigned long) in RSAKeyImpl.o
  "_BN_num_bits", referenced from:
      Poco::Crypto::RSAKeyImpl::convertToByteVec(bignum_st const*) in RSAKeyImpl.o
  "_BN_set_word", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(int, unsigned long) in RSAKeyImpl.o
  "_CONF_modules_free", referenced from:
      Poco::Crypto::OpenSSLInitializer::uninitialize() in OpenSSLInitializer.o
  "_CRYPTO_get_locking_callback", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
  "_CRYPTO_num_locks", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
  "_CRYPTO_set_dynlock_create_callback", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
      Poco::Crypto::OpenSSLInitializer::uninitialize() in OpenSSLInitializer.o
  "_CRYPTO_set_dynlock_destroy_callback", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
      Poco::Crypto::OpenSSLInitializer::uninitialize() in OpenSSLInitializer.o
  "_CRYPTO_set_dynlock_lock_callback", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
      Poco::Crypto::OpenSSLInitializer::uninitialize() in OpenSSLInitializer.o
  "_CRYPTO_set_id_callback", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
      Poco::Crypto::OpenSSLInitializer::uninitialize() in OpenSSLInitializer.o
  "_CRYPTO_set_locking_callback", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
      Poco::Crypto::OpenSSLInitializer::uninitialize() in OpenSSLInitializer.o
  "_ERR_error_string", referenced from:
      Poco::Crypto::(anonymous namespace)::throwError() in CipherImpl.o
      Poco::Crypto::(anonymous namespace)::throwError() in RSACipherImpl.o
  "_ERR_free_strings", referenced from:
      Poco::Crypto::OpenSSLInitializer::uninitialize() in OpenSSLInitializer.o
  "_ERR_get_error", referenced from:
      Poco::Crypto::(anonymous namespace)::throwError() in CipherImpl.o
      Poco::Crypto::(anonymous namespace)::throwError() in RSACipherImpl.o
  "_EVP_BytesToKey", referenced from:
      Poco::Crypto::CipherKeyImpl::generateKey(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) in CipherKeyImpl.o
  "_EVP_CIPHER_CTX_block_size", referenced from:
      Poco::Crypto::(anonymous namespace)::CryptoTransformImpl::blockSize() const in CipherImpl.o
  "_EVP_CIPHER_CTX_cleanup", referenced from:
      Poco::Crypto::(anonymous namespace)::CryptoTransformImpl::~CryptoTransformImpl() in CipherImpl.o
  "_EVP_CIPHER_CTX_set_padding", referenced from:
      Poco::Crypto::(anonymous namespace)::CryptoTransformImpl::setPadding(int) in CipherImpl.o
  "_EVP_CIPHER_block_size", referenced from:
      Poco::Crypto::CipherKeyImpl::blockSize() const in CipherKeyImpl.o
  "_EVP_CIPHER_flags", referenced from:
      Poco::Crypto::CipherKeyImpl::mode() const in CipherKeyImpl.o
  "_EVP_CIPHER_iv_length", referenced from:
      Poco::Crypto::CipherKeyImpl::ivSize() const in CipherKeyImpl.o
  "_EVP_CIPHER_key_length", referenced from:
      Poco::Crypto::CipherKeyImpl::keySize() const in CipherKeyImpl.o
  "_EVP_CipherFinal_ex", referenced from:
      Poco::Crypto::(anonymous namespace)::CryptoTransformImpl::finalize(unsigned char*, int) in CipherImpl.o
  "_EVP_CipherInit", referenced from:
      Poco::Crypto::(anonymous namespace)::CryptoTransformImpl::CryptoTransformImpl(evp_cipher_st const*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, Poco::Crypto::(anonymous namespace)::CryptoTransformImpl::Direction) in CipherImpl.o
  "_EVP_CipherUpdate", referenced from:
      Poco::Crypto::(anonymous namespace)::CryptoTransformImpl::transform(unsigned char const*, int, unsigned char*, int) in CipherImpl.o
  "_EVP_DigestFinal_ex", referenced from:
      Poco::Crypto::DigestEngine::digest() in DigestEngine.o
  "_EVP_DigestInit_ex", referenced from:
      Poco::Crypto::DigestEngine::DigestEngine(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in DigestEngine.o
      Poco::Crypto::DigestEngine::reset() in DigestEngine.o
  "_EVP_DigestUpdate", referenced from:
      Poco::Crypto::DigestEngine::updateImpl(void const*, unsigned long) in DigestEngine.o
  "_EVP_MD_CTX_cleanup", referenced from:
      Poco::Crypto::DigestEngine::reset() in DigestEngine.o
  "_EVP_MD_CTX_create", referenced from:
      Poco::Crypto::DigestEngine::DigestEngine(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in DigestEngine.o
  "_EVP_MD_CTX_destroy", referenced from:
      Poco::Crypto::DigestEngine::~DigestEngine() in DigestEngine.o
  "_EVP_MD_CTX_md", referenced from:
      Poco::Crypto::DigestEngine::digestLength() const in DigestEngine.o
      Poco::Crypto::DigestEngine::digest() in DigestEngine.o
  "_EVP_MD_size", referenced from:
      Poco::Crypto::DigestEngine::digestLength() const in DigestEngine.o
      Poco::Crypto::DigestEngine::digest() in DigestEngine.o
  "_EVP_MD_type", referenced from:
      Poco::Crypto::DigestEngine::nid() const in DigestEngine.o
  "_EVP_PKEY_free", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(Poco::Crypto::X509Certificate const&) in RSAKeyImpl.o
      Poco::Crypto::X509Certificate::issuedBy(Poco::Crypto::X509Certificate const&) const in X509Certificate.o
  "_EVP_PKEY_get1_RSA", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(Poco::Crypto::X509Certificate const&) in RSAKeyImpl.o
  "_EVP_cleanup", referenced from:
      Poco::Crypto::OpenSSLInitializer::uninitialize() in OpenSSLInitializer.o
  "_EVP_des_ede3_cbc", referenced from:
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
  "_EVP_get_cipherbyname", referenced from:
      Poco::Crypto::CipherKeyImpl::CipherKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in CipherKeyImpl.o
      Poco::Crypto::CipherKeyImpl::CipherKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) in CipherKeyImpl.o
      Poco::Crypto::CipherKeyImpl::CipherKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in CipherKeyImpl.o
  "_EVP_get_digestbyname", referenced from:
      Poco::Crypto::CipherKeyImpl::CipherKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in CipherKeyImpl.o
      Poco::Crypto::DigestEngine::DigestEngine(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in DigestEngine.o
      Poco::Crypto::DigestEngine::reset() in DigestEngine.o
  "_GENERAL_NAMES_free", referenced from:
      Poco::Crypto::X509Certificate::extractNames(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) const in X509Certificate.o
  "_OPENSSL_add_all_algorithms_noconf", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
  "_OPENSSL_config", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
  "_PEM_read_bio_RSAPrivateKey", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
  "_PEM_read_bio_RSAPublicKey", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
  "_PEM_read_bio_RSA_PUBKEY", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
  "_PEM_read_bio_X509", referenced from:
      Poco::Crypto::X509Certificate::load(std::__1::basic_istream<char, std::__1::char_traits<char> >&) in X509Certificate.o
      Poco::Crypto::X509Certificate::load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in X509Certificate.o
  "_PEM_write_bio_RSAPrivateKey", referenced from:
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
  "_PEM_write_bio_RSAPublicKey", referenced from:
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_ostream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
  "_PEM_write_bio_X509", referenced from:
      Poco::Crypto::X509Certificate::save(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in X509Certificate.o
      Poco::Crypto::X509Certificate::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in X509Certificate.o
  "_RAND_seed", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
  "_RSA_free", referenced from:
      Poco::Crypto::RSAKeyImpl::freeRSA() in RSAKeyImpl.o
  "_RSA_generate_key_ex", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(int, unsigned long) in RSAKeyImpl.o
  "_RSA_new", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(int, unsigned long) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_istream<char, std::__1::char_traits<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in RSAKeyImpl.o
  "_RSA_private_decrypt", referenced from:
      Poco::Crypto::(anonymous namespace)::RSADecryptImpl::transform(unsigned char const*, int, unsigned char*, int) in RSACipherImpl.o
      Poco::Crypto::(anonymous namespace)::RSADecryptImpl::finalize(unsigned char*, int) in RSACipherImpl.o
  "_RSA_public_encrypt", referenced from:
      Poco::Crypto::(anonymous namespace)::RSAEncryptImpl::transform(unsigned char const*, int, unsigned char*, int) in RSACipherImpl.o
      Poco::Crypto::(anonymous namespace)::RSAEncryptImpl::finalize(unsigned char*, int) in RSACipherImpl.o
  "_RSA_sign", referenced from:
      Poco::Crypto::RSADigestEngine::signature() in RSADigestEngine.o
  "_RSA_size", referenced from:
      Poco::Crypto::(anonymous namespace)::RSAEncryptImpl::blockSize() const in RSACipherImpl.o
      Poco::Crypto::(anonymous namespace)::RSADecryptImpl::blockSize() const in RSACipherImpl.o
      Poco::Crypto::RSAKeyImpl::size() const in RSAKeyImpl.o
  "_RSA_verify", referenced from:
      Poco::Crypto::RSADigestEngine::verify(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) in RSADigestEngine.o
  "_SSL_library_init", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
  "_SSL_load_error_strings", referenced from:
      Poco::Crypto::OpenSSLInitializer::initialize() in OpenSSLInitializer.o
  "_X509_NAME_get_text_by_NID", referenced from:
      Poco::Crypto::X509Certificate::subjectName(Poco::Crypto::X509Certificate::NID) const in X509Certificate.o
      Poco::Crypto::X509Certificate::issuerName(Poco::Crypto::X509Certificate::NID) const in X509Certificate.o
  "_X509_NAME_oneline", referenced from:
      Poco::Crypto::X509Certificate::init() in X509Certificate.o
  "_X509_dup", referenced from:
      Poco::Crypto::X509Certificate::X509Certificate(Poco::Crypto::X509Certificate const&) in X509Certificate.o
  "_X509_free", referenced from:
      Poco::Crypto::X509Certificate::~X509Certificate() in X509Certificate.o
  "_X509_get_ext_d2i", referenced from:
      Poco::Crypto::X509Certificate::extractNames(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) const in X509Certificate.o
  "_X509_get_issuer_name", referenced from:
      Poco::Crypto::X509Certificate::init() in X509Certificate.o
      Poco::Crypto::X509Certificate::issuerName(Poco::Crypto::X509Certificate::NID) const in X509Certificate.o
  "_X509_get_pubkey", referenced from:
      Poco::Crypto::RSAKeyImpl::RSAKeyImpl(Poco::Crypto::X509Certificate const&) in RSAKeyImpl.o
      Poco::Crypto::X509Certificate::issuedBy(Poco::Crypto::X509Certificate const&) const in X509Certificate.o
  "_X509_get_subject_name", referenced from:
      Poco::Crypto::X509Certificate::init() in X509Certificate.o
      Poco::Crypto::X509Certificate::subjectName(Poco::Crypto::X509Certificate::NID) const in X509Certificate.o
  "_X509_verify", referenced from:
      Poco::Crypto::X509Certificate::issuedBy(Poco::Crypto::X509Certificate const&) const in X509Certificate.o
  "_sk_num", referenced from:
      Poco::Crypto::X509Certificate::extractNames(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) const in X509Certificate.o
  "_sk_value", referenced from:
      Poco::Crypto::X509Certificate::extractNames(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) const in X509Certificate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [/Users/    Cupidvogel/Desktop/Poco1.7/pocodyn/poco-develop/lib/Darwin/i386/libPocoCryptod.40.dylib] Error 1
make: *** [Crypto-libexec] Error 2
Cupidvogel@a45e60e70789~/Desktop/Poco1.7/pocodyn/poco-develop$ 
AttitudeMonger commented 8 years ago

Probably the ld: warning: ld: warning: ignoring file /usr/local/opt/openssl//lib/libcrypto.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/opt/openssl//lib/libcrypto.dylibignoring file /usr/local/opt/openssl//lib/libssl.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/opt/openssl//lib/libssl.dylib is the root cause.

zosrothko commented 8 years ago

You are linking a 32 bit application (Poco) with a x86_64 lib (openssl). This cannot work. You should use the 32 bit openssl lib which you should specify with --library-path= on the configure step

AttitudeMonger commented 8 years ago

Yes, but that error did not show up when I was building statically. Why during dynamic library building does it look for the libs? It is required only during run-time, right?

zosrothko commented 8 years ago

It depends on the underlying system.. On WIndows, you need a static version of a lib -- a lib.a -- when linking an application that will use this former lib as a dynamic shared module -- a lib.so --... So I presume it is the same on OSX....

AttitudeMonger commented 8 years ago

Okay. Anyways, it built fine with the library path specified. Built dynamic libs for OpenSSl as well. Now linking them all together..

AttitudeMonger commented 8 years ago

Yeah, with dynamic linking (for both), it builds and compiles fine with my project. I tried sending a POST request to an insecure host, it worked fine as well. Now going to try sending it to a secure host (this caused the entire problem from the beginning!).

zosrothko commented 8 years ago

Glad to see some progress on your side... Let us know when this issue can be closed.

AttitudeMonger commented 8 years ago

Sigh. Now getting this error while trying to send the POST request to a secure host (when I am using just securehost.com instead of https://securehost.com):

SSL Exception: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

This is what works fine with curl:

curl -v -s -k -X POST -H "Content-Type: text/plain" --data-binary <path_to_upload_file> "https://securehost.com/upload?key=<upload_filename>&key1=abcde123&key2=<some_key>&format=<some_format>"

And this is what I am trying with Poco:

try {
        HTTPRequest request(HTTPRequest::HTTP_POST, "/upload?key=<upload_filename>&key1=abcde123&key2=<some_key>&format=<some_format>",HTTPMessage::HTTP_1_1);
        request.setContentType("application/x-www-form-urlencoded");
        request.setKeepAlive(true);
        HTMLForm form;
        form.setEncoding(HTMLForm::ENCODING_MULTIPART);
        form.addPart("file", new FilePartSource("/Users/Cupidvogel/Desktop/POST/qoo.log"));
        form.prepareSubmit(request);

        HTTPSClientSession *httpsSession = new HTTPSClientSession("https://securehost.com");
        httpsSession->setKeepAlive(true);
        httpsSession->setTimeout(Poco::Timespan(20, 0));
        form.write(httpsSession->sendRequest(request));

        Poco::Net::HTTPResponse res;
        std::istream &is = httpsSession->receiveResponse(res);
        Poco::StreamCopier::copyStream(is, std::cout);
        qDebug() << "Message: " << is.rdbuf() << endl;
    }
    catch (Exception &ex)
    {
        qDebug() << "Damn: " << ex.displayText().c_str() << endl;
    }

And I am getting a Host not found: https://securehost.com error. This was the same error I was getting when I was using HTTPClientSession instead of HTTPSClientSession, so I thought that is the problem, that's why I downloaded the full package and tried to build it (and had all these problems). But even now I am getting the same error. :(

Help?

AttitudeMonger commented 8 years ago

Basically I ma back to ground zero. :(

obiltschnig commented 8 years ago

Your problem is here:

HTTPSClientSession *httpsSession = new HTTPSClientSession("https://securehost.com");

You need to pass a hostname and an optional port number to HTTP[S]ClientSession, not a URI.

AttitudeMonger commented 8 years ago

Umm, I didn't get you. Can you give an example? I don't know the port number required for my example. With curl I did not need one. ss

obiltschnig commented 8 years ago

Default port numbers (80 for HTTP, 443 for HTTPS) are usually fine.

So:

HTTPSClientSession *httpsSession = new HTTPSClientSession("securehost.com");

should work.

AttitudeMonger commented 8 years ago

The same example was working when I was trying HTTPClientSession with localhost (insecure). Of course that had a port number required, which I was setting separately, 8080.

AttitudeMonger commented 8 years ago

That' what I mentioned in my earlier comment first, right? That when I am trying just the host name, I am getting this error:

SSL Exception: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed