Переглянути джерело

Add SSL parameters to the example

bel 8 роки тому
батько
коміт
3545edf973
1 змінених файлів з 19 додано та 4 видалено
  1. 19 4
      examples/embedded_c/embedded_c.c

+ 19 - 4
examples/embedded_c/embedded_c.c

@@ -359,10 +359,6 @@ field_get_checksum(const char *key,
                    void *user_data)
                    void *user_data)
 {
 {
 	struct tfiles_checksums *context = (struct tfiles_checksums *)user_data;
 	struct tfiles_checksums *context = (struct tfiles_checksums *)user_data;
-
-	char path[1026];
-	FILE *f;
-
 	(void)key;
 	(void)key;
 
 
 	context->file[context->index - 1].length += valuelen;
 	context->file[context->index - 1].length += valuelen;
@@ -638,6 +634,17 @@ InformWebsockets(struct mg_context *ctx)
 #endif
 #endif
 
 
 
 
+#ifndef NO_SSL
+int
+init_ssl(void *ssl_context, void *user_data)
+{
+	/* Add application specific SSL initialization */
+
+	return 0;
+}
+#endif
+
+
 int
 int
 main(int argc, char *argv[])
 main(int argc, char *argv[])
 {
 {
@@ -656,6 +663,10 @@ main(int argc, char *argv[])
 #ifndef NO_SSL
 #ifndef NO_SSL
 	                         "ssl_certificate",
 	                         "ssl_certificate",
 	                         "../../resources/cert/server.pem",
 	                         "../../resources/cert/server.pem",
+                             "ssl_protocol_version",
+                             "3",
+                             "ssl_cipher_list",
+                             "DES-CBC3-SHA:AES128-SHA:AES128-GCM-SHA256"
 #endif
 #endif
 	                         0};
 	                         0};
 	struct mg_callbacks callbacks;
 	struct mg_callbacks callbacks;
@@ -696,6 +707,9 @@ main(int argc, char *argv[])
 
 
 	/* Start CivetWeb web server */
 	/* Start CivetWeb web server */
 	memset(&callbacks, 0, sizeof(callbacks));
 	memset(&callbacks, 0, sizeof(callbacks));
+#ifndef NO_SSL
+	callbacks.init_ssl = init_ssl;
+#endif
 	ctx = mg_start(&callbacks, 0, options);
 	ctx = mg_start(&callbacks, 0, options);
 
 
 	/* Add handler EXAMPLE_URI, to explain the example */
 	/* Add handler EXAMPLE_URI, to explain the example */
@@ -813,3 +827,4 @@ main(int argc, char *argv[])
 
 
 	return EXIT_SUCCESS;
 	return EXIT_SUCCESS;
 }
 }
+