• C++ OpenSSL

    C/C++, Programming

    Finally, here I am giving you a C++ tutorial on how to implement OpenSSL in C++ either for windows or Linux.

    The video will guide you on how to compile, trouble shoot and link to libraries.

    For windows, you need to extract the ZIP file from this URL [Google Code: OpenSSL for Windows] and copy the required folders and files as instructed in the video.

    If you have any question please do not hesitate to leave comments below.

    Below are the following requirements that have to be installed.


    1. Minimalist GNU for Windows or MingW then choose g++ compiler
    2. Includes file and library files including DLLs


    1. The g++ compiler or simple "sudo apt-get install g++"
    2. Use the latest openssl or simple upgrade it by using this commad "sudo get-apt install openssl"

    Here is to define variables

    // For this example, we'll be testing on openssl.org
    #define SERVER  "www.openssl.org"
    #define PORT 443

    Here to construct the header

      header.append("GET / HTTP1.1\r\n");
      header.append("Host: ").append(SERVER).append("\r\n");
      header.append("User-Agent: Mozilla/5.0\r\n");
      header.append("Content-Type: application/x-www-form-urlencoded\r\n");

    Next sending the content in one go

    sslWrite (c, (char*)header.c_str());

    To read from the server response

      char buffer[1024];
      while(sslread(c, buffer, 1024) != 0)
        printf("%s", buffer);

    Disconnect the socket

    sslDisconnect (c);

    If you prefer to use windows, you need to call this functions from the start and end of the program.


    void startup()
    #ifdef WIN32
        WSADATA wsaData;
        if(WSAStartup(MAKEWORD(2, 2), &wsaData))


    void cleanup()
    #ifdef WIN32


    If you cannot play the video please visit from this URL [Youtube: C++ OpenSSL] and subscribe to receive updates whenever I upload new videos.

  • blog comments powered by Disqus
  • Support Us
  • Help this website up and running by buying me a coffee for only $0.50.