aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/https/test_tls_authentication.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/https/test_tls_authentication.c')
-rw-r--r--src/testcurl/https/test_tls_authentication.c67
1 files changed, 35 insertions, 32 deletions
diff --git a/src/testcurl/https/test_tls_authentication.c b/src/testcurl/https/test_tls_authentication.c
index 2ed8f14c..51fb5331 100644
--- a/src/testcurl/https/test_tls_authentication.c
+++ b/src/testcurl/https/test_tls_authentication.c
@@ -41,38 +41,41 @@ extern const char srv_signed_key_pem[];
41 41
42/* perform a HTTP GET request via SSL/TLS */ 42/* perform a HTTP GET request via SSL/TLS */
43static int 43static int
44test_secure_get (void * cls, char *cipher_suite, int proto_version) 44test_secure_get (void *cls, char *cipher_suite, int proto_version)
45{ 45{
46 int ret; 46 int ret;
47 struct MHD_Daemon *d; 47 struct MHD_Daemon *d;
48 int port; 48 int port;
49 (void)cls; /* Unused. Silent compiler warning. */ 49 (void) cls; /* Unused. Silent compiler warning. */
50 50
51 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 51 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
52 port = 0; 52 port = 0;
53 else 53 else
54 port = 3070; 54 port = 3070;
55 55
56 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | 56 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
57 MHD_USE_ERROR_LOG, port, 57 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS
58 | MHD_USE_ERROR_LOG, port,
58 NULL, NULL, &http_ahc, NULL, 59 NULL, NULL, &http_ahc, NULL,
59 MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, 60 MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem,
60 MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, 61 MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem,
61 MHD_OPTION_END); 62 MHD_OPTION_END);
62 63
63 if (d == NULL) 64 if (d == NULL)
64 { 65 {
65 fprintf (stderr, MHD_E_SERVER_INIT); 66 fprintf (stderr, MHD_E_SERVER_INIT);
66 return -1; 67 return -1;
67 } 68 }
68 if (0 == port) 69 if (0 == port)
70 {
71 const union MHD_DaemonInfo *dinfo;
72 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
73 if ((NULL == dinfo) ||(0 == dinfo->port) )
69 { 74 {
70 const union MHD_DaemonInfo *dinfo; 75 MHD_stop_daemon (d); return -1;
71 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
72 if (NULL == dinfo || 0 == dinfo->port)
73 { MHD_stop_daemon (d); return -1; }
74 port = (int)dinfo->port;
75 } 76 }
77 port = (int) dinfo->port;
78 }
76 79
77 ret = test_daemon_get (NULL, cipher_suite, proto_version, port, 0); 80 ret = test_daemon_get (NULL, cipher_suite, proto_version, port, 0);
78 81
@@ -87,8 +90,8 @@ main (int argc, char *const *argv)
87 unsigned int errorCount = 0; 90 unsigned int errorCount = 0;
88 char *aes256_sha = "AES256-SHA"; 91 char *aes256_sha = "AES256-SHA";
89 FILE *crt; 92 FILE *crt;
90 (void)argc; 93 (void) argc;
91 (void)argv; /* Unused. Silent compiler warning. */ 94 (void) argv; /* Unused. Silent compiler warning. */
92 95
93#ifdef MHD_HTTPS_REQUIRE_GRYPT 96#ifdef MHD_HTTPS_REQUIRE_GRYPT
94 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); 97 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
@@ -96,26 +99,26 @@ main (int argc, char *const *argv)
96 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 99 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
97#endif 100#endif
98#endif /* MHD_HTTPS_REQUIRE_GRYPT */ 101#endif /* MHD_HTTPS_REQUIRE_GRYPT */
99 if (!testsuite_curl_global_init ()) 102 if (! testsuite_curl_global_init ())
100 return 99; 103 return 99;
101 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) 104 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
102 { 105 {
103 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); 106 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
104 curl_global_cleanup (); 107 curl_global_cleanup ();
105 return 77; 108 return 77;
106 } 109 }
107 110
108 if (NULL == (crt = setup_ca_cert ())) 111 if (NULL == (crt = setup_ca_cert ()))
109 { 112 {
110 fprintf (stderr, MHD_E_TEST_FILE_CREAT); 113 fprintf (stderr, MHD_E_TEST_FILE_CREAT);
111 curl_global_cleanup (); 114 curl_global_cleanup ();
112 return 99; 115 return 99;
113 } 116 }
114 fclose (crt); 117 fclose (crt);
115 if (curl_uses_nss_ssl() == 0) 118 if (curl_uses_nss_ssl () == 0)
116 { 119 {
117 aes256_sha = "rsa_aes_256_sha"; 120 aes256_sha = "rsa_aes_256_sha";
118 } 121 }
119 122
120 errorCount += 123 errorCount +=
121 test_secure_get (NULL, aes256_sha, CURL_SSLVERSION_TLSv1); 124 test_secure_get (NULL, aes256_sha, CURL_SSLVERSION_TLSv1);
@@ -125,7 +128,7 @@ main (int argc, char *const *argv)
125 curl_global_cleanup (); 128 curl_global_cleanup ();
126 if (0 != remove (ca_cert_file_name)) 129 if (0 != remove (ca_cert_file_name))
127 fprintf (stderr, 130 fprintf (stderr,
128 "Failed to remove `%s'\n", 131 "Failed to remove `%s'\n",
129 ca_cert_file_name); 132 ca_cert_file_name);
130 return errorCount != 0 ? 1 : 0; 133 return errorCount != 0 ? 1 : 0;
131} 134}