/* perform a HTTP GET request via SSL/TLS */ static int test_secure_get (FILE * test_fd, const char *cipher_suite, int proto_version) { int ret; struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | MHD_USE_DEBUG, 4233, NULL, NULL, &http_ahc, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (d == NULL) { fprintf (stderr, MHD_E_SERVER_INIT); return -1; } ret = test_https_transfer (test_fd, cipher_suite, proto_version); MHD_stop_daemon (d); return ret; }
/** * used when spawning multiple threads executing curl server requests * */ static void * https_transfer_thread_adapter (void *args) { static int nonnull; struct https_test_data *cargs = args; int ret; /* time spread incomming requests */ usleep ((useconds_t) 10.0 * ((double) rand ()) / ((double) RAND_MAX)); ret = test_https_transfer (cargs->cls, cargs->cipher_suite, cargs->proto_version); if (ret == 0) return NULL; return &nonnull; }
/* perform a HTTP GET request via SSL/TLS */ static int test_secure_get (FILE * test_fd, const char *cipher_suite, int proto_version) { int ret; struct MHD_Daemon *d; int port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3041; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, port, NULL, NULL, &http_ahc, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (d == NULL) { fprintf (stderr, MHD_E_SERVER_INIT); return -1; } if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if (NULL == dinfo || 0 == dinfo->port) { MHD_stop_daemon (d); return -1; } port = (int)dinfo->port; } ret = test_https_transfer (test_fd, port, cipher_suite, proto_version); MHD_stop_daemon (d); return ret; }