title: boost asio ssl async_shutdown always finishes with an error?
body: <p>I have a small ssl client that I've programmed in boost 1.55 asio, and I'm trying to figure out why <code>boost::asio::ssl::stream::async_shutdown()</code> always fails. The client is very similar (almost identical) to the ssl client examples in the boost documentation, in that it goes through an <code>boost::asio::ip::tcp::resolver::async_resolve()</code> -> <code>boost::asio::ssl::stream::async_connect()</code> -> <code>boost::asio::ssl::stream::async_handshake()</code> callback sequence. All of this works as expected and the <code>async_handshake()</code> callback gets an all-clear <code>boost::system::error_code</code>.</p>
  
  <p>From the <code>async_handshake()</code> callback, I call <code>async_shutdown()</code> (I don't transfer any data - this object is more for testing the handshake):</p>
  
  <pre><code>void ClientCertificateFinder::handle_handshake(const boost::system::error_code&amp; e)
  {
      if ( !e )
      {
          m_socket.async_shutdown( boost::bind( &amp;ClientCertificateFinder::handle_shutdown_after_success, 
              this, 
              boost::asio::placeholders::error ) );
      }
      else
      {
          m_handler( e, IssuerNameList() );
      }
  }
  </code></pre>
  
  <p><code>handle_shutdown_after_success()</code> is then called, but always with an error? The error is value=2 in <code>asio.misc</code>, which is 'End of file'. I've tried this with a variety of ssl servers, and I always seem to get this <code>asio.misc</code> error. That this isn't an underlying openssl error suggests to me that I might be misusing asio in some way...?</p>
  
  <p>Anyone know why this might be happening? I was under the impression that shutting down the connection with <code>async_shutdown()</code> was The Right Thing To Do, but I guess I could just call <code>boost::asio::ssl::stream.lowestlayer().close()</code> to close the socket out from under openssl if that's the expected way to do this (and indeed the asio ssl examples seem to indicate that this is the right way of shutting down). </p>