Boost logo

Boost :

Subject: [boost] Asio and SSL problem
From: Berserker (berserker_r_at_[hidden])
Date: 2008-09-05 10:14:27

I tried to post this problem in the asio mailing list but I hadn't any feedback, so I'm reporting it here with the hope that someone can help me.

I have a "stack overflow" problem with the following code (using boost 1.36):

void test_handshake(const std::string &host, const std::string &cert)
   boost::asio::io_service service;

   boost::asio::ssl::context sslContext(service, boost::asio::ssl::context::sslv23);
   boost::asio::ip::tcp::resolver resolver(service);
   boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(boost::asio::ip::tcp::resolver::query(host, "443"));
   boost::asio::ip::tcp::resolver::iterator end;

   boost::asio::ssl::stream<boost::asio::ip::tcp::socket> sslSocket(service, sslContext);
   boost::system::error_code error = boost::asio::error::host_not_found;
   while(error && endpoint_iterator != end)
      sslSocket.next_layer().connect(*endpoint_iterator++, error);
      throw boost::system::system_error(error);


   // bla bla

When I call this function with a valid certificate for the host I have no problems, but when I pass a "custom" cerificate (not valid for the host specified) it results in a stack overflow error instead of throwing an exception as I expected...

This example works:

test_handshake("", "cacerts.pem"); // grab cacerts.pem from here for example:

This causes, as I said, a stack overflow instead of an exception:

test_handshake("", "ca.pem"); // ca.pem was taken from the asio examples

Plz help

P.S.: is anyone using asio with ssl? It's very strange that nobody has reported this problem...

Cerchi un locale per la serata? Chiedilo a Live Maps!

Boost list run by bdawes at, gregod at, cpdaniel at, john at