I try to add SSL to my web server implemented with mongoose, but I don't manage to make it work. I have openssl installed and I try to follow the documentation there https://github.com/cesanta/mongoose/blob/master/docs/SSL.md
I have SSL enable:
#define NS_ENABLE_SSL
This is my main function:
int main(int argc, char *argv[]) {
struct mg_server *server;
char port[10] = "8000";
const char * _port;
if (argc > 1) {
strcpy(port, argv[1]);
}
// Create and configure the server
server = mg_create_server(NULL, ev_handler);
mg_set_option(server, "listening_port", port);
_port = mg_get_option(server, "listening_port");
if (strlen(_port)) {
printf("Starting on port %s\n", _port);
for (;;) {
mg_poll_server(server, 1000);
}
}
else {
printf("Cannot start on port %s\n", port);
}
// Cleanup, and free server instance
mg_destroy_server(&server);
return 0;
}
And I have case MG_AUTH: return MG_TRUE; in ev_handler function.
I run my server with:
sudo ./hihttpd 80,ssl://443:ssl.pem
ssl.pem is in the same folder as hihttpd.
https://127.0.0.1/ return me SSL connection error :-/
You can checkout everything on githut https://github.com/apiel/hihttpd/blob/master/hihttpd.c