How do I use OpenSSL with WinSock?

jjxtra picture jjxtra · Jun 17, 2009 · Viewed 7.2k times · Source

I've scoured the web and have not found anything for this...

Does anyone have a simple code sample of using WinSock with OpenSSL? I am looking for a simple Visual C++ 2005 or greater code sample that creates and opens a winsock connection and applies the necessary SSL settings using OpenSSL and frees all resources appropriately.

Answer

Len Holgate picture Len Holgate · Jun 18, 2009

Back in 2002 I wrote an article for Windows Developer Magazine that showed how to use OpenSSL to provide SSL for MFC's CAsyncSocket. The code and article and might help you though it does go further than you might need in that the main focus is not the winsock integration but using OpenSSL with asynchronous winsock. I've used this as the basis of integrating OpenSSL with an I/O completion based high performance winsock server.