aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/https/test_https_session_info.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/https/test_https_session_info.c')
-rw-r--r--src/testcurl/https/test_https_session_info.c113
1 files changed, 57 insertions, 56 deletions
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c
index 45f13981..b692af15 100644
--- a/src/testcurl/https/test_https_session_info.c
+++ b/src/testcurl/https/test_https_session_info.c
@@ -49,41 +49,41 @@ query_session_ahc (void *cls, struct MHD_Connection *connection,
49{ 49{
50 struct MHD_Response *response; 50 struct MHD_Response *response;
51 int ret; 51 int ret;
52 (void)cls;(void)url;(void)method;(void)version; /* Unused. Silent compiler warning. */ 52 (void) cls; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */
53 (void)upload_data;(void)upload_data_size; /* Unused. Silent compiler warning. */ 53 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
54 54
55 if (NULL == *ptr) 55 if (NULL == *ptr)
56 { 56 {
57 *ptr = (void*)&query_session_ahc; 57 *ptr = (void*) &query_session_ahc;
58 return MHD_YES; 58 return MHD_YES;
59 } 59 }
60 60
61 if (GNUTLS_TLS1_1 != 61 if (GNUTLS_TLS1_1 !=
62 (ret = MHD_get_connection_info 62 (ret = MHD_get_connection_info
63 (connection, 63 (connection,
64 MHD_CONNECTION_INFO_PROTOCOL)->protocol)) 64 MHD_CONNECTION_INFO_PROTOCOL)->protocol))
65 {
66 if (GNUTLS_TLS1_2 == ret)
67 {
68 /* as usual, TLS implementations sometimes don't
69 quite do what was asked, just mildly complain... */
70 fprintf (stderr,
71 "Warning: requested TLS 1.1, got TLS 1.2\n");
72 }
73 else
65 { 74 {
66 if (GNUTLS_TLS1_2 == ret) 75 /* really different version... */
67 { 76 fprintf (stderr,
68 /* as usual, TLS implementations sometimes don't 77 "Error: requested protocol mismatch (wanted %d, got %d)\n",
69 quite do what was asked, just mildly complain... */ 78 GNUTLS_TLS1_1,
70 fprintf (stderr, 79 ret);
71 "Warning: requested TLS 1.1, got TLS 1.2\n"); 80 return -1;
72 }
73 else
74 {
75 /* really different version... */
76 fprintf (stderr,
77 "Error: requested protocol mismatch (wanted %d, got %d)\n",
78 GNUTLS_TLS1_1,
79 ret);
80 return -1;
81 }
82 } 81 }
82 }
83 83
84 response = MHD_create_response_from_buffer (strlen (EMPTY_PAGE), 84 response = MHD_create_response_from_buffer (strlen (EMPTY_PAGE),
85 (void *) EMPTY_PAGE, 85 (void *) EMPTY_PAGE,
86 MHD_RESPMEM_PERSISTENT); 86 MHD_RESPMEM_PERSISTENT);
87 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 87 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
88 MHD_destroy_response (response); 88 MHD_destroy_response (response);
89 return ret; 89 return ret;
@@ -114,37 +114,38 @@ test_query_session ()
114 cbc.pos = 0; 114 cbc.pos = 0;
115 115
116 /* setup test */ 116 /* setup test */
117 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | 117 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
118 MHD_USE_ERROR_LOG, port, 118 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS
119 | MHD_USE_ERROR_LOG, port,
119 NULL, NULL, &query_session_ahc, NULL, 120 NULL, NULL, &query_session_ahc, NULL,
120 MHD_OPTION_HTTPS_PRIORITIES, "NORMAL:+ARCFOUR-128", 121 MHD_OPTION_HTTPS_PRIORITIES, "NORMAL:+ARCFOUR-128",
121 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 122 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
122 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 123 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
123 MHD_OPTION_END); 124 MHD_OPTION_END);
124 125
125 if (d == NULL) 126 if (d == NULL)
126 { 127 {
127 free (cbc.buf); 128 free (cbc.buf);
128 return 2; 129 return 2;
129 } 130 }
130 if (0 == port) 131 if (0 == port)
132 {
133 const union MHD_DaemonInfo *dinfo;
134 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
135 if ((NULL == dinfo) ||(0 == dinfo->port) )
131 { 136 {
132 const union MHD_DaemonInfo *dinfo; 137 MHD_stop_daemon (d);
133 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); 138 free (cbc.buf);
134 if (NULL == dinfo || 0 == dinfo->port) 139 return 32;
135 {
136 MHD_stop_daemon (d);
137 free (cbc.buf);
138 return 32;
139 }
140 port = (int)dinfo->port;
141 } 140 }
141 port = (int) dinfo->port;
142 }
142 143
143 const char *aes256_sha = "AES256-SHA"; 144 const char *aes256_sha = "AES256-SHA";
144 if (curl_uses_nss_ssl() == 0) 145 if (curl_uses_nss_ssl () == 0)
145 { 146 {
146 aes256_sha = "rsa_aes_256_sha"; 147 aes256_sha = "rsa_aes_256_sha";
147 } 148 }
148 149
149 gen_test_file_url (url, 150 gen_test_file_url (url,
150 sizeof (url), 151 sizeof (url),
@@ -172,15 +173,15 @@ test_query_session ()
172 * crashes on my system! */ 173 * crashes on my system! */
173 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 174 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
174 if (CURLE_OK != (errornum = curl_easy_perform (c))) 175 if (CURLE_OK != (errornum = curl_easy_perform (c)))
175 { 176 {
176 fprintf (stderr, "curl_easy_perform failed: `%s'\n", 177 fprintf (stderr, "curl_easy_perform failed: `%s'\n",
177 curl_easy_strerror (errornum)); 178 curl_easy_strerror (errornum));
178 179
179 MHD_stop_daemon (d); 180 MHD_stop_daemon (d);
180 curl_easy_cleanup (c); 181 curl_easy_cleanup (c);
181 free (cbc.buf); 182 free (cbc.buf);
182 return -1; 183 return -1;
183 } 184 }
184 185
185 curl_easy_cleanup (c); 186 curl_easy_cleanup (c);
186 MHD_stop_daemon (d); 187 MHD_stop_daemon (d);
@@ -195,7 +196,7 @@ main (int argc, char *const *argv)
195#if LIBCURL_VERSION_NUM >= 0x072200 196#if LIBCURL_VERSION_NUM >= 0x072200
196 unsigned int errorCount = 0; 197 unsigned int errorCount = 0;
197 const char *ssl_version; 198 const char *ssl_version;
198 (void)argc; /* Unused. Silent compiler warning. */ 199 (void) argc; /* Unused. Silent compiler warning. */
199 200
200#ifdef MHD_HTTPS_REQUIRE_GRYPT 201#ifdef MHD_HTTPS_REQUIRE_GRYPT
201 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); 202 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
@@ -203,7 +204,7 @@ main (int argc, char *const *argv)
203 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 204 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
204#endif 205#endif
205#endif /* MHD_HTTPS_REQUIRE_GRYPT */ 206#endif /* MHD_HTTPS_REQUIRE_GRYPT */
206 if (!testsuite_curl_global_init ()) 207 if (! testsuite_curl_global_init ())
207 return 99; 208 return 99;
208 209
209 ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; 210 ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version;