diff options
Diffstat (limited to 'src/testcurl/https')
-rw-r--r-- | src/testcurl/https/test_https_session_info.c | 4 | ||||
-rw-r--r-- | src/testcurl/https/test_tls_extensions.c | 4 | ||||
-rw-r--r-- | src/testcurl/https/test_tls_options.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/tls_test_common.c | 82 | ||||
-rw-r--r-- | src/testcurl/https/tls_test_common.h | 27 |
5 files changed, 79 insertions, 45 deletions
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c index eb821240..f21e03b0 100644 --- a/src/testcurl/https/test_https_session_info.c +++ b/src/testcurl/https/test_https_session_info.c | |||
@@ -141,7 +141,9 @@ test_query_session () | |||
141 | aes256_sha = "rsa_aes_256_sha"; | 141 | aes256_sha = "rsa_aes_256_sha"; |
142 | } | 142 | } |
143 | 143 | ||
144 | gen_test_file_url (url, port); | 144 | gen_test_file_url (url, |
145 | sizeof (url), | ||
146 | port); | ||
145 | c = curl_easy_init (); | 147 | c = curl_easy_init (); |
146 | #if DEBUG_HTTPS_TEST | 148 | #if DEBUG_HTTPS_TEST |
147 | curl_easy_setopt (c, CURLOPT_VERBOSE, 1); | 149 | curl_easy_setopt (c, CURLOPT_VERBOSE, 1); |
diff --git a/src/testcurl/https/test_tls_extensions.c b/src/testcurl/https/test_tls_extensions.c index a7bb6d4e..98725ee3 100644 --- a/src/testcurl/https/test_tls_extensions.c +++ b/src/testcurl/https/test_tls_extensions.c | |||
@@ -168,7 +168,9 @@ test_hello_extension (gnutls_session_t session, int port, extensions_t exten_t, | |||
168 | 168 | ||
169 | gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) (long) sd); | 169 | gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) (long) sd); |
170 | 170 | ||
171 | if (gen_test_file_url (url, port)) | 171 | if (gen_test_file_url (url, |
172 | sizeof (url), | ||
173 | port)) | ||
172 | { | 174 | { |
173 | ret = -1; | 175 | ret = -1; |
174 | goto cleanup; | 176 | goto cleanup; |
diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c index a0f053a0..6eed7932 100644 --- a/src/testcurl/https/test_tls_options.c +++ b/src/testcurl/https/test_tls_options.c | |||
@@ -57,10 +57,13 @@ test_unmatching_ssl_version (void * cls, int port, const char *cipher_suite, | |||
57 | cbc.pos = 0; | 57 | cbc.pos = 0; |
58 | 58 | ||
59 | char url[255]; | 59 | char url[255]; |
60 | if (gen_test_file_url (url, port)) | 60 | if (gen_test_file_url (url, |
61 | sizeof (url), | ||
62 | port)) | ||
61 | { | 63 | { |
62 | free (cbc.buf); | 64 | free (cbc.buf); |
63 | fprintf (stderr, "Internal error in gen_test_file_url\n"); | 65 | fprintf (stderr, |
66 | "Internal error in gen_test_file_url\n"); | ||
64 | return -1; | 67 | return -1; |
65 | } | 68 | } |
66 | 69 | ||
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c index 63cb1013..e929334b 100644 --- a/src/testcurl/https/tls_test_common.c +++ b/src/testcurl/https/tls_test_common.c | |||
@@ -84,7 +84,9 @@ test_daemon_get (void *cls, | |||
84 | cbc.pos = 0; | 84 | cbc.pos = 0; |
85 | 85 | ||
86 | /* construct url - this might use doc_path */ | 86 | /* construct url - this might use doc_path */ |
87 | gen_test_file_url (url, port); | 87 | gen_test_file_url (url, |
88 | sizeof (url), | ||
89 | port); | ||
88 | 90 | ||
89 | c = curl_easy_init (); | 91 | c = curl_easy_init (); |
90 | #if DEBUG_HTTPS_TEST | 92 | #if DEBUG_HTTPS_TEST |
@@ -108,7 +110,7 @@ test_daemon_get (void *cls, | |||
108 | curl_easy_setopt (c, CURLOPT_CAINFO, ca_cert_file_name); | 110 | curl_easy_setopt (c, CURLOPT_CAINFO, ca_cert_file_name); |
109 | curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0); | 111 | curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0); |
110 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 112 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
111 | 113 | ||
112 | /* NOTE: use of CONNECTTIMEOUT without also | 114 | /* NOTE: use of CONNECTTIMEOUT without also |
113 | setting NOSIGNAL results in really weird | 115 | setting NOSIGNAL results in really weird |
114 | crashes on my system! */ | 116 | crashes on my system! */ |
@@ -258,12 +260,15 @@ send_curl_req (char *url, struct CBC * cbc, const char *cipher_suite, | |||
258 | /** | 260 | /** |
259 | * compile test file url pointing to the current running directory path | 261 | * compile test file url pointing to the current running directory path |
260 | * | 262 | * |
261 | * @param url - char buffer into which the url is compiled | 263 | * @param[out] url - char buffer into which the url is compiled |
264 | * @param url_len number of bytes available in url | ||
262 | * @param port port to use for the test | 265 | * @param port port to use for the test |
263 | * @return -1 on error | 266 | * @return -1 on error |
264 | */ | 267 | */ |
265 | int | 268 | int |
266 | gen_test_file_url (char *url, int port) | 269 | gen_test_file_url (char *url, |
270 | size_t url_len, | ||
271 | int port) | ||
267 | { | 272 | { |
268 | int ret = 0; | 273 | int ret = 0; |
269 | char *doc_path; | 274 | char *doc_path; |
@@ -279,46 +284,54 @@ gen_test_file_url (char *url, int port) | |||
279 | fprintf (stderr, MHD_E_MEM); | 284 | fprintf (stderr, MHD_E_MEM); |
280 | return -1; | 285 | return -1; |
281 | } | 286 | } |
282 | if (getcwd (doc_path, doc_path_len) == NULL) | 287 | if (NULL == getcwd (doc_path, doc_path_len)) |
283 | { | 288 | { |
284 | fprintf (stderr, "Error: failed to get working directory. %s\n", | 289 | fprintf (stderr, |
290 | "Error: failed to get working directory. %s\n", | ||
285 | strerror (errno)); | 291 | strerror (errno)); |
286 | ret = -1; | 292 | free (doc_path); |
293 | return -1; | ||
287 | } | 294 | } |
288 | #ifdef WINDOWS | 295 | #ifdef WINDOWS |
296 | for (int i = 0; i < doc_path_len; i++) | ||
289 | { | 297 | { |
290 | int i; | 298 | if (doc_path[i] == 0) |
291 | for (i = 0; i < doc_path_len; i++) | 299 | break; |
292 | { | 300 | if (doc_path[i] == '\\') |
293 | if (doc_path[i] == 0) | ||
294 | break; | ||
295 | if (doc_path[i] == '\\') | ||
296 | { | 301 | { |
297 | doc_path[i] = '/'; | 302 | doc_path[i] = '/'; |
298 | } | 303 | } |
299 | if (doc_path[i] != ':') | 304 | if (doc_path[i] != ':') |
300 | continue; | 305 | continue; |
301 | if (i == 0) | 306 | if (i == 0) |
302 | break; | 307 | break; |
303 | doc_path[i] = doc_path[i - 1]; | 308 | doc_path[i] = doc_path[i - 1]; |
304 | doc_path[i - 1] = '/'; | 309 | doc_path[i - 1] = '/'; |
305 | } | ||
306 | } | 310 | } |
307 | #endif | 311 | #endif |
308 | /* construct url - this might use doc_path */ | 312 | /* construct url */ |
309 | if (sprintf (url, "%s:%d%s/%s", "https://127.0.0.1", port, | 313 | if (snprintf (url, |
310 | doc_path, "urlpath") < 0) | 314 | url_len, |
315 | "%s:%d%s/%s", | ||
316 | "https://127.0.0.1", | ||
317 | port, | ||
318 | doc_path, | ||
319 | "urlpath") >= url_len) | ||
311 | ret = -1; | 320 | ret = -1; |
312 | 321 | ||
313 | free (doc_path); | 322 | free (doc_path); |
314 | return ret; | 323 | return ret; |
315 | } | 324 | } |
316 | 325 | ||
326 | |||
317 | /** | 327 | /** |
318 | * test HTTPS file transfer | 328 | * test HTTPS file transfer |
319 | */ | 329 | */ |
320 | int | 330 | int |
321 | test_https_transfer (void *cls, int port, const char *cipher_suite, int proto_version) | 331 | test_https_transfer (void *cls, |
332 | int port, | ||
333 | const char *cipher_suite, | ||
334 | int proto_version) | ||
322 | { | 335 | { |
323 | int len; | 336 | int len; |
324 | int ret = 0; | 337 | int ret = 0; |
@@ -334,13 +347,16 @@ test_https_transfer (void *cls, int port, const char *cipher_suite, int proto_ve | |||
334 | cbc.size = len; | 347 | cbc.size = len; |
335 | cbc.pos = 0; | 348 | cbc.pos = 0; |
336 | 349 | ||
337 | if (gen_test_file_url (url, port)) | 350 | if (gen_test_file_url (url, |
351 | sizeof (url), | ||
352 | port)) | ||
338 | { | 353 | { |
339 | ret = -1; | 354 | ret = -1; |
340 | goto cleanup; | 355 | goto cleanup; |
341 | } | 356 | } |
342 | 357 | ||
343 | if (CURLE_OK != send_curl_req (url, &cbc, cipher_suite, proto_version)) | 358 | if (CURLE_OK != |
359 | send_curl_req (url, &cbc, cipher_suite, proto_version)) | ||
344 | { | 360 | { |
345 | ret = -1; | 361 | ret = -1; |
346 | goto cleanup; | 362 | goto cleanup; |
@@ -348,8 +364,8 @@ test_https_transfer (void *cls, int port, const char *cipher_suite, int proto_ve | |||
348 | 364 | ||
349 | /* compare test file & daemon responce */ | 365 | /* compare test file & daemon responce */ |
350 | if ( (len != strlen (test_data)) || | 366 | if ( (len != strlen (test_data)) || |
351 | (memcmp (cbc.buf, | 367 | (memcmp (cbc.buf, |
352 | test_data, | 368 | test_data, |
353 | len) != 0) ) | 369 | len) != 0) ) |
354 | { | 370 | { |
355 | fprintf (stderr, "Error: local file & received file differ.\n"); | 371 | fprintf (stderr, "Error: local file & received file differ.\n"); |
@@ -404,7 +420,7 @@ teardown_testcase (struct MHD_Daemon *d) | |||
404 | int | 420 | int |
405 | setup_session (gnutls_session_t * session, | 421 | setup_session (gnutls_session_t * session, |
406 | gnutls_datum_t * key, | 422 | gnutls_datum_t * key, |
407 | gnutls_datum_t * cert, | 423 | gnutls_datum_t * cert, |
408 | gnutls_certificate_credentials_t * xcred) | 424 | gnutls_certificate_credentials_t * xcred) |
409 | { | 425 | { |
410 | int ret; | 426 | int ret; |
@@ -413,7 +429,7 @@ setup_session (gnutls_session_t * session, | |||
413 | gnutls_certificate_allocate_credentials (xcred); | 429 | gnutls_certificate_allocate_credentials (xcred); |
414 | key->size = strlen (srv_key_pem) + 1; | 430 | key->size = strlen (srv_key_pem) + 1; |
415 | key->data = malloc (key->size); | 431 | key->data = malloc (key->size); |
416 | if (NULL == key->data) | 432 | if (NULL == key->data) |
417 | { | 433 | { |
418 | gnutls_certificate_free_credentials (*xcred); | 434 | gnutls_certificate_free_credentials (*xcred); |
419 | return -1; | 435 | return -1; |
@@ -424,7 +440,7 @@ setup_session (gnutls_session_t * session, | |||
424 | if (NULL == cert->data) | 440 | if (NULL == cert->data) |
425 | { | 441 | { |
426 | gnutls_certificate_free_credentials (*xcred); | 442 | gnutls_certificate_free_credentials (*xcred); |
427 | free (key->data); | 443 | free (key->data); |
428 | return -1; | 444 | return -1; |
429 | } | 445 | } |
430 | memcpy (cert->data, srv_self_signed_cert_pem, cert->size); | 446 | memcpy (cert->data, srv_self_signed_cert_pem, cert->size); |
@@ -440,8 +456,8 @@ setup_session (gnutls_session_t * session, | |||
440 | free (key->data); | 456 | free (key->data); |
441 | return -1; | 457 | return -1; |
442 | } | 458 | } |
443 | gnutls_credentials_set (*session, | 459 | gnutls_credentials_set (*session, |
444 | GNUTLS_CRD_CERTIFICATE, | 460 | GNUTLS_CRD_CERTIFICATE, |
445 | *xcred); | 461 | *xcred); |
446 | return 0; | 462 | return 0; |
447 | } | 463 | } |
diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h index a59c43f4..07849e44 100644 --- a/src/testcurl/https/tls_test_common.h +++ b/src/testcurl/https/tls_test_common.h | |||
@@ -68,12 +68,15 @@ struct CipherDef | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | 70 | ||
71 | int curl_check_version (const char *req_version, ...); | 71 | int |
72 | int curl_uses_nss_ssl (); | 72 | curl_check_version (const char *req_version, ...); |
73 | |||
74 | int | ||
75 | curl_uses_nss_ssl (void); | ||
73 | 76 | ||
74 | 77 | ||
75 | FILE * | 78 | FILE * |
76 | setup_ca_cert (); | 79 | setup_ca_cert (void); |
77 | 80 | ||
78 | /** | 81 | /** |
79 | * perform cURL request for file | 82 | * perform cURL request for file |
@@ -83,9 +86,11 @@ test_daemon_get (void * cls, | |||
83 | const char *cipher_suite, int proto_version, | 86 | const char *cipher_suite, int proto_version, |
84 | int port, int ver_peer); | 87 | int port, int ver_peer); |
85 | 88 | ||
86 | void print_test_result (int test_outcome, char *test_name); | 89 | void |
90 | print_test_result (int test_outcome, char *test_name); | ||
87 | 91 | ||
88 | size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx); | 92 | size_t |
93 | copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx); | ||
89 | 94 | ||
90 | int | 95 | int |
91 | http_ahc (void *cls, struct MHD_Connection *connection, | 96 | http_ahc (void *cls, struct MHD_Connection *connection, |
@@ -102,11 +107,15 @@ http_dummy_ahc (void *cls, struct MHD_Connection *connection, | |||
102 | /** | 107 | /** |
103 | * compile test file url pointing to the current running directory path | 108 | * compile test file url pointing to the current running directory path |
104 | * | 109 | * |
105 | * @param url - char buffer into which the url is compiled | 110 | * @param[out] url - char buffer into which the url is compiled |
111 | * @param url_len number of bytes available in @a url | ||
106 | * @param port port to use for the test | 112 | * @param port port to use for the test |
107 | * @return -1 on error | 113 | * @return -1 on error |
108 | */ | 114 | */ |
109 | int gen_test_file_url (char *url, int port); | 115 | int |
116 | gen_test_file_url (char *url, | ||
117 | size_t url_len, | ||
118 | int port); | ||
110 | 119 | ||
111 | int | 120 | int |
112 | send_curl_req (char *url, struct CBC *cbc, const char *cipher_suite, | 121 | send_curl_req (char *url, struct CBC *cbc, const char *cipher_suite, |
@@ -118,7 +127,9 @@ test_https_transfer (void *cls, int port, const char *cipher_suite, int proto_ve | |||
118 | int | 127 | int |
119 | setup_testcase (struct MHD_Daemon **d, int port, int daemon_flags, va_list arg_list); | 128 | setup_testcase (struct MHD_Daemon **d, int port, int daemon_flags, va_list arg_list); |
120 | 129 | ||
121 | void teardown_testcase (struct MHD_Daemon *d); | 130 | void |
131 | teardown_testcase (struct MHD_Daemon *d); | ||
132 | |||
122 | 133 | ||
123 | int | 134 | int |
124 | setup_session (gnutls_session_t * session, | 135 | setup_session (gnutls_session_t * session, |