[asio] Trying to make SSL work with an existing client/server system

Hello, Our group has created a fairly sophisticated client/server system using ASIO from sourceforge. First off, I would just like to thank the developer(s) for a fantastic library! It greatly simplifies asychronous networking code. My problem lies with retrofitting SSL into our current codebase. We now have the requirement that the end user should be able to specify whether to use SSL or not. So I've been trying to understand and add SSL support....it hasn't gone well so far. Background: I'm compiling with MSVS 7.1 on Windows XP SP2. If someone coulld answer my initial questions, I would greatly appreciate it! :) 1) Are there any tutorials and/or best practices documentation for SSL with ASIO? I haven't found any. The most I've found is some client/server classes that use SSL in libs\asio\example\ssl. Unfortunately, the code doesn't seem to compile without editing because it references the boost::asio namespace and the asio library is currently just in the asio namespace. So, I question how current the example code is. 2) I started to replace our socket code that used asio::stream_socket with asio::ssl::stream<asio::stream_socket>. I added the asio::ssl::context object to the socket constructor, but I'm now getting compile errors like this: ..\API\inc\asio\ssl\detail\openssl_operation.hpp(368) : error C2039: 'read_some' : is not a member of 'asio' ..\API\inc\asio\ssl\detail\openssl_operation.hpp(367) : while compiling class-template member function 'int asio::ssl::detail::openssl_operation<Stream>::do_sync_read(void)' with [ Stream=asio::stream_socket ] ..\API\inc\asio\ssl\detail\openssl_stream_service.hpp(359) : see reference to class template instantiation 'asio::ssl::detail::openssl_operation<Stream>' being compiled with [ Stream=asio::stream_socket ] ..\API\inc\asio\ssl\stream_service.hpp(143) : see reference to function template instantiation 'size_t asio::ssl::detail::openssl_stream_service<Allocator>::read_some<Stream,Mutab le_Buffers,Error_Handler>(asio::ssl::detail::openssl_stream_service<Allocato r>::impl_type & ,Stream &,const Mutable_Buffers &,Error_Handler)' being compiled with [ Allocator=std::allocator<void>, Stream=asio::stream_socket, Mutable_Buffers=asio::detail::consuming_buffers<asio::mutable_buffer_contain er_1>, Error_Handler=asio::detail::assign_error_t<asio::ssl::stream<asio::stream_so cket>::error_type> ] ..\API\inc\asio\ssl\stream.hpp(389) : see reference to function template instantiation 'size_t asio::ssl::stream_service<>::read_some<Stream,Mutable_Buffers,Error_Handler> (asio::ssl::stream_service<>::impl_type & ,Stream &,const Mutable_Buffers &,Error_Handler)' being compiled ... <snip> Anyway, I'll stop here for now. Any pointers on SSL with ASIO would be greatly appreciated! Thanks, Scott

Hi Scott: Scott <cheesy4poofs@cox.net> wrote:
1) Are there any tutorials and/or best practices documentation for SSL with ASIO? I haven't found any. The most I've found is some client/server classes that use SSL in libs\asio\example\ssl. Unfortunately, the code doesn't seem to compile without editing because it references the boost::asio namespace and the asio library is currently just in the asio namespace. So, I question how current the example code is.
It sounds to me as though you're using the SSL example from the "boost layout" asio proposal (where everything is in the namespace boost::asio) with the headers from the non-boost package of asio (where the namespace is just asio). The SSL example is found in src/examples/ssl in the non-boost package.
2) I started to replace our socket code that used asio::stream_socket with asio::ssl::stream<asio::stream_socket>. I added the asio::ssl::context object to the socket constructor, but I'm now getting compile errors like this:
That error has been fixed in CVS. See here: <http://asio.cvs.sourceforge.net/asio/asio/include/asio/ssl/detail/openssl_operation.hpp?r1=1.6&r2=1.7> You may want to download a more recent snapshot of asio from the boost vault (since I presume you're currently using 0.3.6): <http://boost-consulting.com/vault/index.php?directory=Input%20-%20Output> or from asio's anonymous CVS repository on sourceforge. There have also been a couple of other SSL-related bug fixes since 0.3.6. Cheers, Chris
participants (2)
-
Christopher Kohlhoff
-
Scott