expand test to force GnuTLS

This commit is contained in:
Christian Grothoff
2024-11-27 18:43:47 +01:00
parent 2775435621
commit 062efed8b7
3 changed files with 92 additions and 17 deletions
+13
View File
@@ -575,6 +575,19 @@ MHDT_server_setup_tls (const void *cls,
struct MHD_Daemon *d);
/**
* Initialize MHD daemon with TLS support using GnuTLS, binding to any free
* port.
*
* @param cls closure
* @param[in,out] d daemon to initialize
* @return error message, NULL on success
*/
const char *
MHDT_server_setup_gnutls (const void *cls,
struct MHD_Daemon *d);
/**
* Function that runs an MHD daemon until
* a read() against @a finsig succeeds.
+47 -17
View File
@@ -54,11 +54,15 @@ MHDT_server_setup_minimal (const void *cls,
}
const char *
MHDT_server_setup_tls (const void *cls,
struct MHD_Daemon *d)
/**
* Setup TLS at @a d for the given backend @a be.
*
* @return NULL on success, otherwise error message
*/
static const char *
server_setup_tls (struct MHD_Daemon *d,
enum MHD_TlsBackend be)
{
const struct MHD_DaemonOptionAndValue *options = cls;
static const char *mem_cert =
"-----BEGIN CERTIFICATE-----\n\
MIIFJjCCAw6gAwIBAgIBBTANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx\n\
@@ -120,22 +124,10 @@ hW4ncX0UcqFPm7Ahqo9+NDemJlV7DYHRcvL/xVNUbr8yV7OpHILd4Hk/s8J4QGl/\n\
bC1zEehy8q0jMywvSR8vsS1v\n\
-----END PRIVATE KEY-----";
if (MHD_SC_OK !=
MHD_daemon_set_options (
d,
options,
MHD_OPTIONS_ARRAY_MAX_SIZE))
return "Failed to configure threading mode!";
if (MHD_SC_OK !=
MHD_DAEMON_SET_OPTIONS (
d,
MHD_D_OPTION_BIND_PORT (MHD_AF_AUTO,
0)))
return "Failed to bind to port 0!";
if (MHD_SC_OK !=
MHD_DAEMON_SET_OPTIONS (
d,
MHD_D_OPTION_TLS (MHD_TLS_BACKEND_ANY)))
MHD_D_OPTION_TLS (be)))
return "Failed to enable TLS!";
if (MHD_SC_OK !=
MHD_DAEMON_SET_OPTIONS (
@@ -148,6 +140,44 @@ bC1zEehy8q0jMywvSR8vsS1v\n\
}
const char *
MHDT_server_setup_tls (const void *cls,
struct MHD_Daemon *d)
{
const struct MHD_DaemonOptionAndValue *options = cls;
const char *err;
err = MHDT_server_setup_minimal (options,
d);
if (NULL != err)
return err;
err = server_setup_tls (d,
MHD_TLS_BACKEND_ANY);
if (NULL != err)
return err;
return NULL;
}
const char *
MHDT_server_setup_gnutls (const void *cls,
struct MHD_Daemon *d)
{
const struct MHD_DaemonOptionAndValue *options = cls;
const char *err;
err = MHDT_server_setup_minimal (options,
d);
if (NULL != err)
return err;
err = server_setup_tls (d,
MHD_TLS_BACKEND_GNUTLS);
if (NULL != err)
return err;
return NULL;
}
void
MHDT_server_run_minimal (void *cls,
int finsig,
+32
View File
@@ -90,6 +90,14 @@ main (int argc, char *argv[])
.server_setup_cls = thread2select,
.server_runner = &MHDT_server_run_minimal,
},
#if HAVE_GNUTLS_GNUTLS_H
{
.label = "multi-threaded select, forcing GnuTLS",
.server_setup = &MHDT_server_setup_gnutls,
.server_setup_cls = thread2select,
.server_runner = &MHDT_server_run_minimal,
},
#endif
#endif
#ifdef MHD_USE_POLL
{
@@ -104,6 +112,14 @@ main (int argc, char *argv[])
.server_setup_cls = thread2poll,
.server_runner = &MHDT_server_run_minimal,
},
#if HAVE_GNUTLS_GNUTLS_H
{
.label = "multi-threaded poll, forcing GnuTLS",
.server_setup = &MHDT_server_setup_gnutls,
.server_setup_cls = thread2poll,
.server_runner = &MHDT_server_run_minimal,
},
#endif
#endif
#if MHD_USE_EPOLL
{
@@ -118,6 +134,14 @@ main (int argc, char *argv[])
.server_setup_cls = thread2epoll,
.server_runner = &MHDT_server_run_minimal,
},
#if HAVE_GNUTLS_GNUTLS_H
{
.label = "multi-threaded epoll, forcing GnuTLS",
.server_setup = &MHDT_server_setup_gnutls,
.server_setup_cls = thread2epoll,
.server_runner = &MHDT_server_run_minimal,
},
#endif
#endif
{
.label = "auto-selected mode, single threaded",
@@ -125,6 +149,14 @@ main (int argc, char *argv[])
.server_setup_cls = thread1auto,
.server_runner = &MHDT_server_run_minimal,
},
#if HAVE_GNUTLS_GNUTLS_H
{
.label = "auto-selected mode, single threaded, forcing GnuTLS",
.server_setup = &MHDT_server_setup_gnutls,
.server_setup_cls = thread1auto,
.server_runner = &MHDT_server_run_minimal,
},
#endif
#if 1
/* FIXME: remove once MHD_daemon_process_blocking
has been implemented */