Commit 0730590e authored by Sergey Lyubka's avatar Sergey Lyubka Committed by Sergey Lyubka

Fix SSL codepath in restful_server example

    PUBLISHED_FROM=4cd52839b8d2396f50f94f1ce36fa7b4501dc204
parent f7e0b133
......@@ -51,6 +51,9 @@ int main(int argc, char *argv[]) {
struct mg_connection *nc;
int i;
char *cp;
#ifdef NS_ENABLE_SSL
const char *ssl_cert = NULL;
#endif
mg_mgr_init(&mgr, NULL);
......@@ -76,12 +79,7 @@ int main(int argc, char *argv[]) {
#endif
#ifdef NS_ENABLE_SSL
} else if (strcmp(argv[i], "-s") == 0 && i + 1 < argc) {
const char *ssl_cert = argv[++i];
const char *err_str = mg_set_ssl(nc, ssl_cert, NULL);
if (err_str != NULL) {
fprintf(stderr, "Error loading SSL cert: %s\n", err_str);
exit(1);
}
ssl_cert = argv[++i];
#endif
}
}
......@@ -93,6 +91,16 @@ int main(int argc, char *argv[]) {
exit(1);
}
#ifdef NS_ENABLE_SSL
if (ssl_cert != NULL) {
const char *err_str = mg_set_ssl(nc, ssl_cert, NULL);
if (err_str != NULL) {
fprintf(stderr, "Error loading SSL cert: %s\n", err_str);
exit(1);
}
}
#endif
mg_set_protocol_http_websocket(nc);
s_http_server_opts.document_root = ".";
s_http_server_opts.enable_directory_listing = "yes";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment