diff options
Diffstat (limited to 'src/testcurl/https/test_https_session_info.c')
-rw-r--r-- | src/testcurl/https/test_https_session_info.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c index c5c38742..040b4458 100644 --- a/src/testcurl/https/test_https_session_info.c +++ b/src/testcurl/https/test_https_session_info.c | |||
@@ -35,8 +35,6 @@ | |||
35 | #include "tls_test_common.h" | 35 | #include "tls_test_common.h" |
36 | #include "tls_test_keys.h" | 36 | #include "tls_test_keys.h" |
37 | 37 | ||
38 | static struct MHD_Daemon *d; | ||
39 | |||
40 | /* | 38 | /* |
41 | * HTTP access handler call back | 39 | * HTTP access handler call back |
42 | * used to query negotiated security parameters | 40 | * used to query negotiated security parameters |
@@ -101,6 +99,7 @@ test_query_session (enum know_gnutls_tls_id tls_ver, uint16_t *pport) | |||
101 | CURLcode errornum; | 99 | CURLcode errornum; |
102 | char url[256]; | 100 | char url[256]; |
103 | enum know_gnutls_tls_id found_tls_ver; | 101 | enum know_gnutls_tls_id found_tls_ver; |
102 | struct MHD_Daemon *d; | ||
104 | 103 | ||
105 | if (NULL == (cbc.buf = malloc (sizeof (char) * 255))) | 104 | if (NULL == (cbc.buf = malloc (sizeof (char) * 255))) |
106 | return 99; | 105 | return 99; |
@@ -115,15 +114,13 @@ test_query_session (enum know_gnutls_tls_id tls_ver, uint16_t *pport) | |||
115 | NULL, NULL, | 114 | NULL, NULL, |
116 | &query_info_ahc, &found_tls_ver, | 115 | &query_info_ahc, &found_tls_ver, |
117 | MHD_OPTION_HTTPS_PRIORITIES, priorities_map[tls_ver], | 116 | MHD_OPTION_HTTPS_PRIORITIES, priorities_map[tls_ver], |
118 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, | 117 | MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, |
119 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, | 118 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, |
120 | MHD_OPTION_END); | 119 | MHD_OPTION_END); |
121 | 120 | ||
122 | if (d == NULL) | 121 | if (d == NULL) |
123 | { | 122 | { |
124 | free (cbc.buf); | 123 | free (cbc.buf); |
125 | fflush (stderr); | ||
126 | fflush (stdout); | ||
127 | fprintf (stderr, "MHD_start_daemon() with %s failed.\n", | 124 | fprintf (stderr, "MHD_start_daemon() with %s failed.\n", |
128 | tls_names[tls_ver]); | 125 | tls_names[tls_ver]); |
129 | fflush (stderr); | 126 | fflush (stderr); |
@@ -136,11 +133,9 @@ test_query_session (enum know_gnutls_tls_id tls_ver, uint16_t *pport) | |||
136 | if ((NULL == dinfo) || (0 == dinfo->port) ) | 133 | if ((NULL == dinfo) || (0 == dinfo->port) ) |
137 | { | 134 | { |
138 | MHD_stop_daemon (d); | 135 | MHD_stop_daemon (d); |
139 | fflush (stderr); | 136 | free (cbc.buf); |
140 | fflush (stdout); | ||
141 | fprintf (stderr, "MHD_get_daemon_info() failed.\n"); | 137 | fprintf (stderr, "MHD_get_daemon_info() failed.\n"); |
142 | fflush (stderr); | 138 | fflush (stderr); |
143 | free (cbc.buf); | ||
144 | return 10; | 139 | return 10; |
145 | } | 140 | } |
146 | *pport = dinfo->port; /* Use the same port for rest of the checks */ | 141 | *pport = dinfo->port; /* Use the same port for rest of the checks */ |
@@ -150,6 +145,15 @@ test_query_session (enum know_gnutls_tls_id tls_ver, uint16_t *pport) | |||
150 | sizeof (url), | 145 | sizeof (url), |
151 | *pport); | 146 | *pport); |
152 | c = curl_easy_init (); | 147 | c = curl_easy_init (); |
148 | fflush (stderr); | ||
149 | if (NULL == c) | ||
150 | { | ||
151 | fprintf (stderr, "curl_easy_init() failed.\n"); | ||
152 | fflush (stderr); | ||
153 | MHD_stop_daemon (d); | ||
154 | free (cbc.buf); | ||
155 | return 99; | ||
156 | } | ||
153 | #ifdef _DEBUG | 157 | #ifdef _DEBUG |
154 | curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); | 158 | curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); |
155 | #endif | 159 | #endif |
@@ -174,6 +178,9 @@ test_query_session (enum know_gnutls_tls_id tls_ver, uint16_t *pport) | |||
174 | (errornum = curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L))) || | 178 | (errornum = curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L))) || |
175 | (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)))) | 179 | (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)))) |
176 | { | 180 | { |
181 | curl_easy_cleanup (c); | ||
182 | free (cbc.buf); | ||
183 | MHD_stop_daemon (d); | ||
177 | fflush (stderr); | 184 | fflush (stderr); |
178 | fflush (stdout); | 185 | fflush (stdout); |
179 | fprintf (stderr, "Error setting libcurl option: %s.\n", | 186 | fprintf (stderr, "Error setting libcurl option: %s.\n", |
@@ -185,9 +192,9 @@ test_query_session (enum know_gnutls_tls_id tls_ver, uint16_t *pport) | |||
185 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | 192 | if (CURLE_OK != (errornum = curl_easy_perform (c))) |
186 | { | 193 | { |
187 | unsigned int ret; | 194 | unsigned int ret; |
188 | MHD_stop_daemon (d); | ||
189 | curl_easy_cleanup (c); | 195 | curl_easy_cleanup (c); |
190 | free (cbc.buf); | 196 | free (cbc.buf); |
197 | MHD_stop_daemon (d); | ||
191 | 198 | ||
192 | fflush (stderr); | 199 | fflush (stderr); |
193 | fflush (stdout); | 200 | fflush (stdout); |
@@ -211,8 +218,8 @@ test_query_session (enum know_gnutls_tls_id tls_ver, uint16_t *pport) | |||
211 | } | 218 | } |
212 | 219 | ||
213 | curl_easy_cleanup (c); | 220 | curl_easy_cleanup (c); |
214 | MHD_stop_daemon (d); | ||
215 | free (cbc.buf); | 221 | free (cbc.buf); |
222 | MHD_stop_daemon (d); | ||
216 | 223 | ||
217 | if (tls_ver != found_tls_ver) | 224 | if (tls_ver != found_tls_ver) |
218 | { | 225 | { |
@@ -250,10 +257,7 @@ test_all_supported_versions (void) | |||
250 | vers_list = gnutls_protocol_list (); | 257 | vers_list = gnutls_protocol_list (); |
251 | if (NULL == vers_list) | 258 | if (NULL == vers_list) |
252 | { | 259 | { |
253 | fflush (stderr); | ||
254 | fflush (stdout); | ||
255 | fprintf (stderr, "Error getting GnuTLS supported TLS versions"); | 260 | fprintf (stderr, "Error getting GnuTLS supported TLS versions"); |
256 | fflush (stdout); | ||
257 | return 99; | 261 | return 99; |
258 | } | 262 | } |
259 | num_success = 0; | 263 | num_success = 0; |
@@ -271,28 +275,25 @@ test_all_supported_versions (void) | |||
271 | } | 275 | } |
272 | if (0 == *ver_ptr) | 276 | if (0 == *ver_ptr) |
273 | { | 277 | { |
274 | fflush (stderr); | ||
275 | printf ("%s is not supported by GnuTLS, skipping.\n\n", | 278 | printf ("%s is not supported by GnuTLS, skipping.\n\n", |
276 | tls_names[ver_for_test]); | 279 | tls_names[ver_for_test]); |
277 | fflush (stdout); | 280 | fflush (stdout); |
278 | continue; | 281 | continue; |
279 | } | 282 | } |
280 | fflush (stderr); | ||
281 | printf ("Starting check for %s...\n", | 283 | printf ("Starting check for %s...\n", |
282 | tls_names[ver_for_test]); | 284 | tls_names[ver_for_test]); |
283 | fflush (stdout); | 285 | fflush (stdout); |
284 | res = test_query_session (ver_for_test, &port); | 286 | res = test_query_session (ver_for_test, &port); |
287 | fflush (stderr); | ||
288 | fflush (stdout); | ||
285 | if (99 == res) | 289 | if (99 == res) |
286 | { | 290 | { |
287 | fflush (stderr); | ||
288 | fflush (stdout); | ||
289 | fprintf (stderr, "Hard error. Test stopped.\n"); | 291 | fprintf (stderr, "Hard error. Test stopped.\n"); |
290 | fflush (stderr); | 292 | fflush (stderr); |
291 | return 99; | 293 | return 99; |
292 | } | 294 | } |
293 | else if (77 == res) | 295 | else if (77 == res) |
294 | { | 296 | { |
295 | fflush (stderr); | ||
296 | printf ("%s does not work with libcurl client and GnuTLS " | 297 | printf ("%s does not work with libcurl client and GnuTLS " |
297 | "server combination, skipping.\n", | 298 | "server combination, skipping.\n", |
298 | tls_names[ver_for_test]); | 299 | tls_names[ver_for_test]); |
@@ -300,8 +301,6 @@ test_all_supported_versions (void) | |||
300 | } | 301 | } |
301 | else if (0 != res) | 302 | else if (0 != res) |
302 | { | 303 | { |
303 | fflush (stderr); | ||
304 | fflush (stdout); | ||
305 | fprintf (stderr, "Check failed for %s.\n", | 304 | fprintf (stderr, "Check failed for %s.\n", |
306 | tls_names[ver_for_test]); | 305 | tls_names[ver_for_test]); |
307 | fflush (stderr); | 306 | fflush (stderr); |
@@ -309,7 +308,6 @@ test_all_supported_versions (void) | |||
309 | } | 308 | } |
310 | else | 309 | else |
311 | { | 310 | { |
312 | fflush (stderr); | ||
313 | printf ("Check succeeded for %s.\n", | 311 | printf ("Check succeeded for %s.\n", |
314 | tls_names[ver_for_test]); | 312 | tls_names[ver_for_test]); |
315 | fflush (stdout); | 313 | fflush (stdout); |
@@ -323,8 +321,6 @@ test_all_supported_versions (void) | |||
323 | { | 321 | { |
324 | if (0 == num_success) | 322 | if (0 == num_success) |
325 | { | 323 | { |
326 | fflush (stderr); | ||
327 | fflush (stdout); | ||
328 | fprintf (stderr, "No supported TLS version was found.\n"); | 324 | fprintf (stderr, "No supported TLS version was found.\n"); |
329 | fflush (stderr); | 325 | fflush (stderr); |
330 | return 77; | 326 | return 77; |