|  | @@ -4383,7 +4383,7 @@ END_TEST
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  static void
 |  |  static void
 | 
											
												
													
														|  | -minimal_http_client_impl(const char *server, uint16_t port, const char *uri)
 |  | 
 | 
											
												
													
														|  | 
 |  | +minimal_http_https_client_impl(const char *server, uint16_t port, int use_ssl, const char *uri)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |  	/* Client var */
 |  |  	/* Client var */
 | 
											
												
													
														|  |  	struct mg_connection *client;
 |  |  	struct mg_connection *client;
 | 
											
										
											
												
													
														|  | @@ -4396,7 +4396,7 @@ minimal_http_client_impl(const char *server, uint16_t port, const char *uri)
 | 
											
												
													
														|  |  	mark_point();
 |  |  	mark_point();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	client = mg_connect_client(
 |  |  	client = mg_connect_client(
 | 
											
												
													
														|  | -	    server, port, 0, client_err_buf, sizeof(client_err_buf));
 |  | 
 | 
											
												
													
														|  | 
 |  | +            server, port, use_ssl, client_err_buf, sizeof(client_err_buf));
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	ck_assert(client != NULL);
 |  |  	ck_assert(client != NULL);
 | 
											
												
													
														|  |  	ck_assert_str_eq(client_err_buf, "");
 |  |  	ck_assert_str_eq(client_err_buf, "");
 | 
											
										
											
												
													
														|  | @@ -4435,6 +4435,20 @@ minimal_http_client_impl(const char *server, uint16_t port, const char *uri)
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +static void
 | 
											
												
													
														|  | 
 |  | +minimal_http_client_impl(const char *server, uint16_t port, int use_ssl, const char *uri)
 | 
											
												
													
														|  | 
 |  | +{
 | 
											
												
													
														|  | 
 |  | +    minimal_http_https_client_impl(server, port, 0, uri);
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +static void
 | 
											
												
													
														|  | 
 |  | +minimal_https_client_impl(const char *server, uint16_t port, int use_ssl, const char *uri)
 | 
											
												
													
														|  | 
 |  | +{
 | 
											
												
													
														|  | 
 |  | +    minimal_http_https_client_impl(server, port, 1, uri);
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  START_TEST(test_minimal_client)
 |  |  START_TEST(test_minimal_client)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |  	mark_point();
 |  |  	mark_point();
 | 
											
										
											
												
													
														|  | @@ -4482,7 +4496,7 @@ minimal_test_request_handler(struct mg_connection *conn, void *cbdata)
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -START_TEST(test_minimal_server_callback)
 |  | 
 | 
											
												
													
														|  | 
 |  | +START_TEST(test_minimal_http_server_callback)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |  	/* This test should ensure the minimum server example in
 |  |  	/* This test should ensure the minimum server example in
 | 
											
												
													
														|  |  	 * docs/Embedding.md is still running. */
 |  |  	 * docs/Embedding.md is still running. */
 | 
											
										
											
												
													
														|  | @@ -4530,6 +4544,82 @@ START_TEST(test_minimal_server_callback)
 | 
											
												
													
														|  |  END_TEST
 |  |  END_TEST
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +START_TEST(test_minimal_https_server_callback)
 | 
											
												
													
														|  | 
 |  | +{
 | 
											
												
													
														|  | 
 |  | +        /* This test should ensure the minimum server example in
 | 
											
												
													
														|  | 
 |  | +         * docs/Embedding.md is still running. */
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Server context handle */
 | 
											
												
													
														|  | 
 |  | +        struct mg_context *ctx;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Server start parameters for HTTPS */
 | 
											
												
													
														|  | 
 |  | +        const char *OPTIONS[32];
 | 
											
												
													
														|  | 
 |  | +        int opt_cnt = 0;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* HTTPS port - required */
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = "listening_ports";
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = "8443s";
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* path to certificate file - required */
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = "ssl_certificate";
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = locate_ssl_cert();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* set minimum SSL version to TLS 1.2 - recommended */
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = "ssl_protocol_version";
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = "4";
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* set some modern ciphers - recommended */
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = "ssl_cipher_list";
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = "ECDH+AESGCM+AES256:!aNULL:!MD5:!DSS";
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* set "HTTPS only" header - recommended */
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = "strict_transport_security_max_age";
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx++] = "31622400";
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* end of options - required */
 | 
											
												
													
														|  | 
 |  | +        OPTIONS[opt_idx] = NULL;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        mark_point();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Initialize the library */
 | 
											
												
													
														|  | 
 |  | +        mg_init_library(0);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Start the server */
 | 
											
												
													
														|  | 
 |  | +        ctx = test_mg_start(NULL, 0, OPTIONS);
 | 
											
												
													
														|  | 
 |  | +        ck_assert(ctx != NULL);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Add some handler */
 | 
											
												
													
														|  | 
 |  | +        mg_set_request_handler(ctx,
 | 
											
												
													
														|  | 
 |  | +                               "/hello",
 | 
											
												
													
														|  | 
 |  | +                               minimal_test_request_handler,
 | 
											
												
													
														|  | 
 |  | +                               (void *)"Hello world");
 | 
											
												
													
														|  | 
 |  | +        mg_set_request_handler(ctx,
 | 
											
												
													
														|  | 
 |  | +                               "/8",
 | 
											
												
													
														|  | 
 |  | +                               minimal_test_request_handler,
 | 
											
												
													
														|  | 
 |  | +                               (void *)"Number eight");
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Run the server for 15 seconds */
 | 
											
												
													
														|  | 
 |  | +        test_sleep(10);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Call a test client */
 | 
											
												
													
														|  | 
 |  | +        minimal_https_client_impl("127.0.0.1", 8443, "/hello");
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Run the server for 15 seconds */
 | 
											
												
													
														|  | 
 |  | +        test_sleep(5);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Stop the server */
 | 
											
												
													
														|  | 
 |  | +        test_mg_stop(ctx);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        /* Un-initialize the library */
 | 
											
												
													
														|  | 
 |  | +        mg_exit_library();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        mark_point();
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +END_TEST
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  Suite *
 |  |  Suite *
 | 
											
												
													
														|  |  make_public_server_suite(void)
 |  |  make_public_server_suite(void)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
										
											
												
													
														|  | @@ -4568,8 +4658,9 @@ make_public_server_suite(void)
 | 
											
												
													
														|  |  	tcase_set_timeout(tcase_startthreads, civetweb_min_test_timeout);
 |  |  	tcase_set_timeout(tcase_startthreads, civetweb_min_test_timeout);
 | 
											
												
													
														|  |  	suite_add_tcase(suite, tcase_startthreads);
 |  |  	suite_add_tcase(suite, tcase_startthreads);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	tcase_add_test(tcase_minimal_svr, test_minimal_server_callback);
 |  | 
 | 
											
												
													
														|  | -	tcase_set_timeout(tcase_minimal_svr, civetweb_min_server_test_timeout);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        tcase_add_test(tcase_minimal_svr, test_minimal_http_server_callback);
 | 
											
												
													
														|  | 
 |  | +        tcase_add_test(tcase_minimal_svr, test_minimal_https_server_callback);
 | 
											
												
													
														|  | 
 |  | +        tcase_set_timeout(tcase_minimal_svr, civetweb_min_server_test_timeout);
 | 
											
												
													
														|  |  	suite_add_tcase(suite, tcase_minimal_svr);
 |  |  	suite_add_tcase(suite, tcase_minimal_svr);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	tcase_add_test(tcase_minimal_cli, test_minimal_client);
 |  |  	tcase_add_test(tcase_minimal_cli, test_minimal_client);
 |