mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-28 12:30:58 +00:00
Fix SSL codepath in restful_server example
PUBLISHED_FROM=4cd52839b8d2396f50f94f1ce36fa7b4501dc204
This commit is contained in:
1 parent
f7e0b1331c
commit
0730590e35
1 file changed
+14
-6
@@ -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";
|
||||
|
||||
Reference in new issue
Block a user