Creare un semplice server https con httplib

Autore: Fabio Di Matteo
Ultima revisione: 20/06/2024 - 10:17

simple_ssl.cpp

#define CPPHTTPLIB_OPENSSL_SUPPORT
#include "httplib.h"
using namespace httplib;
 
 
 
int main(void) 
{
	httplib::SSLServer svr("./cert.pem","./key.pem");
 
	svr.Get("/", [](const Request & /*req*/, Response &res) {
		res.set_content("Hello World!", "text/plain");
	});
 
	svr.listen("0.0.0.0", 8080);
}

makefile

all:
 
  g++  simple_ssl.cpp -o simple_ssl -lssl -lcrypto