EXPECT_FALSE(ctx);
}
+// Disabled tests for obsolete OpenSSL or Botan
+#ifdef WITH_OPENSSL
+#if defined(LIBRESSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+
// Define a callback class.
namespace { // anonymous namespace.
service.run_one();
}
EXPECT_TRUE(server_cb.getCode());
-#ifdef WITH_OPENSSL
#ifndef LIBRESSL_VERSION_NUMBER
-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
string server_expected("wrong version number");
-#else
- string server_expected("unknown protocol");
-#endif
#else
string server_expected("tlsv1 alert protocol version");
-#endif
#endif
EXPECT_EQ(server_expected, server_cb.getCode().message());
EXPECT_FALSE(client_cb.getCode());
EXPECT_TRUE(server_cb.getCode());
// Full error is:
// error 20 at 0 depth lookup:unable to get local issuer certificate
-#ifdef WITH_OPENSSL
#ifndef LIBRESSL_VERSION_NUMBER
string server_expected("certificate verify failed");
#else
string server_expected("tlsv1 alert unknown ca");
#endif
EXPECT_EQ(server_expected, server_cb.getCode().message());
-#if defined(LIBRESSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER >= 0x10100000L)
EXPECT_FALSE(client_cb.getCode());
-#endif
-#endif
// Close client and server.
EXPECT_NO_THROW(client.lowest_layer().close());
EXPECT_TRUE(server_cb.getCode());
// Full error is:
// error 18 at 0 depth lookup:self signed certificate
-#ifdef WITH_OPENSSL
#ifndef LIBRESSL_VERSION_NUMBER
string server_expected("certificate verify failed");
#else
string server_expected("tlsv1 alert unknown ca");
#endif
EXPECT_EQ(server_expected, server_cb.getCode().message());
-#if defined(LIBRESSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER >= 0x10100000L)
EXPECT_FALSE(client_cb.getCode());
-#endif
-#endif
// Close client and server.
EXPECT_NO_THROW(client.lowest_layer().close());
EXPECT_NO_THROW(server.lowest_layer().close());
}
-
-
-
-
-
-
-
-
+#endif // defined(LIBRESSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+#endif // WITH_OPENSSL
openssl_sample_client_SOURCES = openssl_sample_client.cc
openssl_sample_client_CPPFLAGS = $(AM_CPPFLAGS)
openssl_sample_client_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS)
-openssl_sample_client_LDADD = $(CRYPTO_LIBS)
+openssl_sample_client_LDADD = $(BOOST_LIBS) $(CRYPTO_LIBS)
openssl_sample_server_SOURCES = openssl_sample_server.cc
openssl_sample_server_CPPFLAGS = $(AM_CPPFLAGS)
openssl_sample_server_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS)
-openssl_sample_server_LDADD = $(CRYPTO_LIBS)
+openssl_sample_server_LDADD = $(BOOST_LIBS) $(CRYPTO_LIBS)
endif
endif
#include <config.h>
+#ifdef HAVE_GENERIC_TLS_METHOD
+
#include <cstdlib>
#include <cstring>
#include <functional>
public:
client(boost::asio::io_service& io_context,
boost::asio::ssl::context& context,
- const tcp::resolver::results_type& endpoints)
+ const tcp::endpoint& endpoint)
: socket_(io_context, context)
{
socket_.set_verify_mode(boost::asio::ssl::verify_peer |
socket_.set_verify_callback(
std::bind(&client::verify_certificate, this, _1, _2));
- connect(endpoints);
+ connect(endpoint);
}
private:
return preverified;
}
- void connect(const tcp::resolver::results_type& endpoints)
+ void connect(const tcp::endpoint& endpoint)
{
- boost::asio::async_connect(socket_.lowest_layer(), endpoints,
- [this](const boost::system::error_code& error,
- const tcp::endpoint& /*endpoint*/)
+ socket_.lowest_layer().async_connect(endpoint,
+ [this](const boost::system::error_code& error)
{
if (!error)
{
{
if (argc != 3)
{
- std::cerr << "Usage: client <host> <port>\n";
+ std::cerr << "Usage: client <addr> <port>\n";
return 1;
}
boost::asio::io_service io_context;
- tcp::resolver resolver(io_context);
- auto endpoints = resolver.resolve(argv[1], argv[2]);
+ using namespace std; // For atoi.
+ tcp::endpoint endpoint(
+ boost::asio::ip::address::from_string(argv[1]), atoi(argv[2]));
-#ifdef HAVE_GENERIC_TLS_METHOD
boost::asio::ssl::context ctx(boost::asio::ssl::context::method::tls);
-#else
-#ifdef HAVE_TLS_1_2_METHOD
- boost::asio::ssl::context ctx(boost::asio::ssl::context::method::tlsv12);
-#else
- boost::asio::ssl::context ctx(boost::asio::ssl::context::method::tlsv1);
-#endif
-#endif
ctx.load_verify_file(CA_("kea-ca.crt"));
ctx.use_certificate_chain_file(CA_("kea-client.crt"));
ctx.use_private_key_file(CA_("kea-client.key"),
boost::asio::ssl::context::pem);
- client c(io_context, ctx, endpoints);
+ client c(io_context, ctx, endpoint);
io_context.run();
}
return 0;
}
+#else // !HAVE_GENERIC_TLS_METHOD
+
+#include <iostream>
+
+int main()
+{
+ std::cerr << "this tool requires recent boost version\n";
+ return 0;
+}
+#endif
#include <config.h>
+#ifdef HAVE_GENERIC_TLS_METHOD
+
#include <cstdlib>
#include <iostream>
#include <boost/bind/bind.hpp>
: io_context_(io_context),
acceptor_(io_context,
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)),
-#ifdef HAVE_GENERIC_TLS_METHOD
context_(boost::asio::ssl::context::method::tls)
-#else
-#ifdef HAVE_TLS_1_2_METHOD
- context_(boost::asio::ssl::context::method::tlsv12)
-#else
- context_(boost::asio::ssl::context::method::tlsv1)
-#endif
-#endif
{
//context_.set_options(
// boost::asio::ssl::context::default_workarounds
return 0;
}
+
+#else // !HAVE_GENERIC_TLS_METHOD
+
+#include <iostream>
+
+int main()
+{
+ std::cerr << "this tool requires recent boost version\n";
+ return 0;
+}
+#endif
+