aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/https/test_https_get.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/https/test_https_get.c')
-rw-r--r--src/testcurl/https/test_https_get.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c
index 61c25643..17248bf7 100644
--- a/src/testcurl/https/test_https_get.c
+++ b/src/testcurl/https/test_https_get.c
@@ -39,9 +39,9 @@ extern const char srv_signed_key_pem[];
39 39
40/* perform a HTTP GET request via SSL/TLS */ 40/* perform a HTTP GET request via SSL/TLS */
41static int 41static int
42test_secure_get (FILE * test_fd, 42test_secure_get (FILE *test_fd,
43 const char *cipher_suite, 43 const char *cipher_suite,
44 int proto_version) 44 int proto_version)
45{ 45{
46 int ret; 46 int ret;
47 struct MHD_Daemon *d; 47 struct MHD_Daemon *d;
@@ -52,26 +52,29 @@ test_secure_get (FILE * test_fd,
52 else 52 else
53 port = 3041; 53 port = 3041;
54 54
55 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | 55 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
56 MHD_USE_ERROR_LOG, port, 56 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS
57 | MHD_USE_ERROR_LOG, port,
57 NULL, NULL, &http_ahc, NULL, 58 NULL, NULL, &http_ahc, NULL,
58 MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, 59 MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem,
59 MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, 60 MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem,
60 MHD_OPTION_END); 61 MHD_OPTION_END);
61 62
62 if (d == NULL) 63 if (d == NULL)
63 { 64 {
64 fprintf (stderr, MHD_E_SERVER_INIT); 65 fprintf (stderr, MHD_E_SERVER_INIT);
65 return -1; 66 return -1;
66 } 67 }
67 if (0 == port) 68 if (0 == port)
69 {
70 const union MHD_DaemonInfo *dinfo;
71 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
72 if ((NULL == dinfo) ||(0 == dinfo->port) )
68 { 73 {
69 const union MHD_DaemonInfo *dinfo; 74 MHD_stop_daemon (d); return -1;
70 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
71 if (NULL == dinfo || 0 == dinfo->port)
72 { MHD_stop_daemon (d); return -1; }
73 port = (int)dinfo->port;
74 } 75 }
76 port = (int) dinfo->port;
77 }
75 78
76 ret = test_https_transfer (test_fd, port, cipher_suite, proto_version); 79 ret = test_https_transfer (test_fd, port, cipher_suite, proto_version);
77 80
@@ -85,7 +88,7 @@ main (int argc, char *const *argv)
85{ 88{
86 unsigned int errorCount = 0; 89 unsigned int errorCount = 0;
87 const char *aes256_sha_tlsv1 = "AES256-SHA"; 90 const char *aes256_sha_tlsv1 = "AES256-SHA";
88 (void)argc; /* Unused. Silent compiler warning. */ 91 (void) argc; /* Unused. Silent compiler warning. */
89 92
90#ifdef MHD_HTTPS_REQUIRE_GRYPT 93#ifdef MHD_HTTPS_REQUIRE_GRYPT
91 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); 94 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
@@ -93,19 +96,19 @@ main (int argc, char *const *argv)
93 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 96 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
94#endif 97#endif
95#endif /* MHD_HTTPS_REQUIRE_GRYPT */ 98#endif /* MHD_HTTPS_REQUIRE_GRYPT */
96 if (!testsuite_curl_global_init ()) 99 if (! testsuite_curl_global_init ())
97 return 99; 100 return 99;
98 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) 101 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
99 { 102 {
100 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); 103 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
101 curl_global_cleanup (); 104 curl_global_cleanup ();
102 return 77; 105 return 77;
103 } 106 }
104 107
105 if (curl_uses_nss_ssl() == 0) 108 if (curl_uses_nss_ssl () == 0)
106 { 109 {
107 aes256_sha_tlsv1 = "rsa_aes_256_sha"; 110 aes256_sha_tlsv1 = "rsa_aes_256_sha";
108 } 111 }
109 112
110 errorCount += 113 errorCount +=
111 test_secure_get (NULL, aes256_sha_tlsv1, CURL_SSLVERSION_TLSv1); 114 test_secure_get (NULL, aes256_sha_tlsv1, CURL_SSLVERSION_TLSv1);