aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/https
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/https')
-rw-r--r--src/testcurl/https/Makefile.am16
-rw-r--r--src/testcurl/https/mhds_get_test.c6
-rw-r--r--src/testcurl/https/mhds_session_info_test.c4
-rw-r--r--src/testcurl/https/tls_alert_test.c46
-rw-r--r--src/testcurl/https/tls_cipher_change_test.c32
-rw-r--r--src/testcurl/https/tls_daemon_options_test.c18
-rw-r--r--src/testcurl/https/tls_extension_test.c42
-rw-r--r--src/testcurl/https/tls_multi_thread_mode_test.c4
-rw-r--r--src/testcurl/https/tls_session_time_out_test.c73
-rw-r--r--src/testcurl/https/tls_test_common.c66
-rw-r--r--src/testcurl/https/tls_test_common.h18
-rw-r--r--src/testcurl/https/tls_thread_mode_test.c4
12 files changed, 122 insertions, 207 deletions
diff --git a/src/testcurl/https/Makefile.am b/src/testcurl/https/Makefile.am
index d707bda0..42791bdc 100644
--- a/src/testcurl/https/Makefile.am
+++ b/src/testcurl/https/Makefile.am
@@ -6,10 +6,6 @@ endif
6 6
7AM_CPPFLAGS = \ 7AM_CPPFLAGS = \
8 -I$(top_srcdir)/src/include \ 8 -I$(top_srcdir)/src/include \
9 -I$(top_srcdir)/src/daemon/https \
10 -I$(top_srcdir)/src/daemon/https/tls \
11 -I$(top_srcdir)/src/daemon/https/lgl \
12 -I$(top_srcdir)/src/daemon/https/x509 \
13 -I$(top_srcdir)/src/daemon \ 9 -I$(top_srcdir)/src/daemon \
14 $(LIBCURL_CPPFLAGS) 10 $(LIBCURL_CPPFLAGS)
15 11
@@ -23,8 +19,7 @@ check_PROGRAMS = \
23 tls_multi_thread_mode_test \ 19 tls_multi_thread_mode_test \
24 tls_session_time_out_test \ 20 tls_session_time_out_test \
25 tls_cipher_change_test \ 21 tls_cipher_change_test \
26 tls_alert_test \ 22 tls_alert_test
27 tls_extension_test
28 23
29EXTRA_DIST = cert.pem key.pem tls_test_keys.h tls_test_common.h 24EXTRA_DIST = cert.pem key.pem tls_test_keys.h tls_test_common.h
30 25
@@ -39,18 +34,9 @@ TESTS = \
39 tls_session_time_out_test \ 34 tls_session_time_out_test \
40 tls_cipher_change_test \ 35 tls_cipher_change_test \
41 tls_alert_test \ 36 tls_alert_test \
42 tls_extension_test \
43 tls_authentication_test 37 tls_authentication_test
44 38
45# cURL dependent tests 39# cURL dependent tests
46tls_extension_test_SOURCES = \
47 tls_extension_test.c \
48 tls_test_common.c
49tls_extension_test_LDADD = \
50 $(top_builddir)/src/testcurl/libcurl_version_check.a \
51 $(top_builddir)/src/daemon/libmicrohttpd.la \
52 @LIBCURL@
53
54tls_session_time_out_test_SOURCES = \ 40tls_session_time_out_test_SOURCES = \
55 tls_session_time_out_test.c \ 41 tls_session_time_out_test.c \
56 tls_test_common.c 42 tls_test_common.c
diff --git a/src/testcurl/https/mhds_get_test.c b/src/testcurl/https/mhds_get_test.c
index ce0fcbda..a32b2cff 100644
--- a/src/testcurl/https/mhds_get_test.c
+++ b/src/testcurl/https/mhds_get_test.c
@@ -26,13 +26,9 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "microhttpd.h" 28#include "microhttpd.h"
29
30#include <limits.h> 29#include <limits.h>
31#include <sys/stat.h> 30#include <sys/stat.h>
32
33#include "gnutls.h"
34#include <curl/curl.h> 31#include <curl/curl.h>
35
36#include "tls_test_common.h" 32#include "tls_test_common.h"
37 33
38int curl_check_version (const char *req_version, ...); 34int curl_check_version (const char *req_version, ...);
@@ -46,7 +42,7 @@ test_cipher_option (FILE * test_fd, char *cipher_suite, int proto_version)
46{ 42{
47 43
48 int ret; 44 int ret;
49 int ciper[] = { MHD_GNUTLS_CIPHER_3DES_CBC, 0 }; 45 int ciper[] = { GNUTLS_CIPHER_3DES_CBC, 0 };
50 struct MHD_Daemon *d; 46 struct MHD_Daemon *d;
51 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 47 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
52 MHD_USE_DEBUG, 42433, 48 MHD_USE_DEBUG, 42433,
diff --git a/src/testcurl/https/mhds_session_info_test.c b/src/testcurl/https/mhds_session_info_test.c
index da0c2cdd..93985604 100644
--- a/src/testcurl/https/mhds_session_info_test.c
+++ b/src/testcurl/https/mhds_session_info_test.c
@@ -53,7 +53,7 @@ query_session_ahc (void *cls, struct MHD_Connection *connection,
53 if (MHD_get_connection_info 53 if (MHD_get_connection_info
54 (connection, 54 (connection,
55 MHD_CONNECTION_INFO_CIPHER_ALGO)->cipher_algorithm != 55 MHD_CONNECTION_INFO_CIPHER_ALGO)->cipher_algorithm !=
56 MHD_GNUTLS_CIPHER_AES_256_CBC) 56 GNUTLS_CIPHER_AES_256_CBC)
57 { 57 {
58 fprintf (stderr, "Error: requested cipher mismatch. %s\n", 58 fprintf (stderr, "Error: requested cipher mismatch. %s\n",
59 strerror (errno)); 59 strerror (errno));
@@ -62,7 +62,7 @@ query_session_ahc (void *cls, struct MHD_Connection *connection,
62 62
63 if (MHD_get_connection_info 63 if (MHD_get_connection_info
64 (connection, 64 (connection,
65 MHD_CONNECTION_INFO_PROTOCOL)->protocol != MHD_GNUTLS_PROTOCOL_SSL3) 65 MHD_CONNECTION_INFO_PROTOCOL)->protocol != GNUTLS_SSL3)
66 { 66 {
67 fprintf (stderr, "Error: requested compression mismatch. %s\n", 67 fprintf (stderr, "Error: requested compression mismatch. %s\n",
68 strerror (errno)); 68 strerror (errno));
diff --git a/src/testcurl/https/tls_alert_test.c b/src/testcurl/https/tls_alert_test.c
index b9d08100..45b1505a 100644
--- a/src/testcurl/https/tls_alert_test.c
+++ b/src/testcurl/https/tls_alert_test.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file mhds_get_test.c 22 * @file tls_alert_test.c
23 * @brief: daemon TLS alert response test-case 23 * @brief: daemon TLS alert response test-case
24 * 24 *
25 * @author Sagie Amir 25 * @author Sagie Amir
@@ -27,11 +27,8 @@
27 27
28#include "platform.h" 28#include "platform.h"
29#include "microhttpd.h" 29#include "microhttpd.h"
30#include "gnutls_int.h"
31#include "gnutls_datum.h"
32#include "gnutls_record.h"
33
34#include "tls_test_common.h" 30#include "tls_test_common.h"
31
35extern const char srv_key_pem[]; 32extern const char srv_key_pem[];
36extern const char srv_self_signed_cert_pem[]; 33extern const char srv_self_signed_cert_pem[];
37 34
@@ -42,7 +39,7 @@ extern const char srv_self_signed_cert_pem[];
42 * @param session: an initialized TLS session 39 * @param session: an initialized TLS session
43 */ 40 */
44static int 41static int
45test_alert_close_notify (MHD_gtls_session_t session) 42test_alert_close_notify (gnutls_session_t session)
46{ 43{
47 int sd, ret; 44 int sd, ret;
48 struct sockaddr_in sa; 45 struct sockaddr_in sa;
@@ -59,7 +56,7 @@ test_alert_close_notify (MHD_gtls_session_t session)
59 sa.sin_port = htons (DEAMON_TEST_PORT); 56 sa.sin_port = htons (DEAMON_TEST_PORT);
60 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); 57 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr);
61 58
62 MHD__gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) (long) sd); 59 gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) (long) sd);
63 60
64 ret = connect (sd, &sa, sizeof (struct sockaddr_in)); 61 ret = connect (sd, &sa, sizeof (struct sockaddr_in));
65 62
@@ -69,16 +66,17 @@ test_alert_close_notify (MHD_gtls_session_t session)
69 return -1; 66 return -1;
70 } 67 }
71 68
72 ret = MHD__gnutls_handshake (session); 69 ret = gnutls_handshake (session);
73 if (ret < 0) 70 if (ret < 0)
74 { 71 {
75 return -1; 72 return -1;
76 } 73 }
77 74
78 MHD__gnutls_alert_send (session, GNUTLS_AL_FATAL, GNUTLS_A_CLOSE_NOTIFY); 75 gnutls_alert_send (session, GNUTLS_AL_FATAL, GNUTLS_A_CLOSE_NOTIFY);
79 76
77#if FIXME_GHM
80 /* check server responds with a 'close-notify' */ 78 /* check server responds with a 'close-notify' */
81 MHD_gtls_recv_int (session, GNUTLS_ALERT, GNUTLS_HANDSHAKE_FINISHED, 0, 0); 79 gnutls_recv_int (session, GNUTLS_ALERT, GNUTLS_HANDSHAKE_FINISHED, 0, 0);
82 80
83 close (sd); 81 close (sd);
84 /* CLOSE_NOTIFY */ 82 /* CLOSE_NOTIFY */
@@ -86,7 +84,7 @@ test_alert_close_notify (MHD_gtls_session_t session)
86 { 84 {
87 return -1; 85 return -1;
88 } 86 }
89 87#endif
90 return 0; 88 return 0;
91} 89}
92 90
@@ -97,7 +95,7 @@ test_alert_close_notify (MHD_gtls_session_t session)
97 * @param session: an initialized TLS session 95 * @param session: an initialized TLS session
98 */ 96 */
99static int 97static int
100test_alert_unexpected_message (MHD_gtls_session_t session) 98test_alert_unexpected_message (gnutls_session_t session)
101{ 99{
102 int sd, ret; 100 int sd, ret;
103 struct sockaddr_in sa; 101 struct sockaddr_in sa;
@@ -113,8 +111,8 @@ test_alert_unexpected_message (MHD_gtls_session_t session)
113 sa.sin_port = htons (DEAMON_TEST_PORT); 111 sa.sin_port = htons (DEAMON_TEST_PORT);
114 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); 112 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr);
115 113
116 MHD__gnutls_transport_set_ptr (session, 114 gnutls_transport_set_ptr (session,
117 (MHD_gnutls_transport_ptr_t) ((void *) (long) sd)); 115 (gnutls_transport_ptr_t) ((void *) (long) sd));
118 116
119 ret = connect (sd, &sa, sizeof (struct sockaddr_in)); 117 ret = connect (sd, &sa, sizeof (struct sockaddr_in));
120 118
@@ -124,14 +122,14 @@ test_alert_unexpected_message (MHD_gtls_session_t session)
124 return -1; 122 return -1;
125 } 123 }
126 124
127 ret = MHD__gnutls_handshake (session); 125 ret = gnutls_handshake (session);
128 if (ret < 0) 126 if (ret < 0)
129 { 127 {
130 return -1; 128 return -1;
131 } 129 }
132 130
133 MHD__gnutls_alert_send (session, GNUTLS_AL_FATAL, 131 gnutls_alert_send (session, GNUTLS_AL_FATAL,
134 GNUTLS_A_UNEXPECTED_MESSAGE); 132 GNUTLS_A_UNEXPECTED_MESSAGE);
135 usleep (100); 133 usleep (100);
136 134
137 /* TODO better RST trigger */ 135 /* TODO better RST trigger */
@@ -149,13 +147,13 @@ main (int argc, char *const *argv)
149{ 147{
150 int errorCount = 0;; 148 int errorCount = 0;;
151 struct MHD_Daemon *d; 149 struct MHD_Daemon *d;
152 MHD_gtls_session_t session; 150 gnutls_session_t session;
153 MHD_gnutls_datum_t key; 151 gnutls_datum_t key;
154 MHD_gnutls_datum_t cert; 152 gnutls_datum_t cert;
155 MHD_gtls_cert_credentials_t xcred; 153 gnutls_certificate_credentials_t xcred;
156 154
157 MHD__gnutls_global_init (); 155 gnutls_global_init ();
158 MHD_gtls_global_set_log_level (11); 156 gnutls_global_set_log_level (11);
159 157
160 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 158 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
161 MHD_USE_DEBUG, DEAMON_TEST_PORT, 159 MHD_USE_DEBUG, DEAMON_TEST_PORT,
@@ -181,7 +179,7 @@ main (int argc, char *const *argv)
181 print_test_result (errorCount, argv[0]); 179 print_test_result (errorCount, argv[0]);
182 180
183 MHD_stop_daemon (d); 181 MHD_stop_daemon (d);
184 MHD__gnutls_global_deinit (); 182 gnutls_global_deinit ();
185 183
186 return errorCount != 0; 184 return errorCount != 0;
187} 185}
diff --git a/src/testcurl/https/tls_cipher_change_test.c b/src/testcurl/https/tls_cipher_change_test.c
index 48ba50de..61c1ab5f 100644
--- a/src/testcurl/https/tls_cipher_change_test.c
+++ b/src/testcurl/https/tls_cipher_change_test.c
@@ -28,11 +28,8 @@
28#include "platform.h" 28#include "platform.h"
29#include "microhttpd.h" 29#include "microhttpd.h"
30#include "internal.h" 30#include "internal.h"
31#include "gnutls_int.h"
32#include "gnutls_datum.h"
33#include "gnutls_record.h"
34
35#include "tls_test_common.h" 31#include "tls_test_common.h"
32
36extern const char srv_key_pem[]; 33extern const char srv_key_pem[];
37extern const char srv_self_signed_cert_pem[]; 34extern const char srv_self_signed_cert_pem[];
38 35
@@ -47,7 +44,7 @@ rehandshake_ahc (void *cls, struct MHD_Connection *connection,
47{ 44{
48 int ret; 45 int ret;
49 /* server side re-handshake request */ 46 /* server side re-handshake request */
50 ret = MHD__gnutls_rehandshake (connection->tls_session); 47 ret = gnutls_rehandshake (connection->tls_session);
51 48
52 if (ret < 0) 49 if (ret < 0)
53 { 50 {
@@ -67,7 +64,7 @@ rehandshake_ahc (void *cls, struct MHD_Connection *connection,
67 * @param session: initiallized TLS session 64 * @param session: initiallized TLS session
68 */ 65 */
69static int 66static int
70test_out_of_context_cipher_change (MHD_gtls_session_t session) 67test_out_of_context_cipher_change (gnutls_session_t session)
71{ 68{
72 int sd, ret; 69 int sd, ret;
73 struct sockaddr_in sa; 70 struct sockaddr_in sa;
@@ -84,7 +81,7 @@ test_out_of_context_cipher_change (MHD_gtls_session_t session)
84 sa.sin_port = htons (DEAMON_TEST_PORT); 81 sa.sin_port = htons (DEAMON_TEST_PORT);
85 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); 82 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr);
86 83
87 MHD__gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) (long) sd); 84 gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) (long) sd);
88 85
89 ret = connect (sd, &sa, sizeof (struct sockaddr_in)); 86 ret = connect (sd, &sa, sizeof (struct sockaddr_in));
90 87
@@ -94,15 +91,16 @@ test_out_of_context_cipher_change (MHD_gtls_session_t session)
94 return -1; 91 return -1;
95 } 92 }
96 93
97 ret = MHD__gnutls_handshake (session); 94 ret = gnutls_handshake (session);
98 if (ret < 0) 95 if (ret < 0)
99 { 96 {
100 return -1; 97 return -1;
101 } 98 }
102 99
100#if FIXME_GHM
103 /* send an out of context cipher change spec */ 101 /* send an out of context cipher change spec */
104 MHD_gtls_send_change_cipher_spec (session, 0); 102 gnutls_send_change_cipher_spec (session, 0);
105 103#endif
106 104
107 /* assert server has closed connection */ 105 /* assert server has closed connection */
108 /* TODO better RST trigger */ 106 /* TODO better RST trigger */
@@ -120,13 +118,13 @@ main (int argc, char *const *argv)
120{ 118{
121 int errorCount = 0;; 119 int errorCount = 0;;
122 struct MHD_Daemon *d; 120 struct MHD_Daemon *d;
123 MHD_gtls_session_t session; 121 gnutls_session_t session;
124 MHD_gnutls_datum_t key; 122 gnutls_datum_t key;
125 MHD_gnutls_datum_t cert; 123 gnutls_datum_t cert;
126 MHD_gtls_cert_credentials_t xcred; 124 gnutls_certificate_credentials_t xcred;
127 125
128 MHD__gnutls_global_init (); 126 gnutls_global_init ();
129 MHD_gtls_global_set_log_level (11); 127 gnutls_global_set_log_level (11);
130 128
131 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 129 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
132 MHD_USE_DEBUG, DEAMON_TEST_PORT, 130 MHD_USE_DEBUG, DEAMON_TEST_PORT,
@@ -148,7 +146,7 @@ main (int argc, char *const *argv)
148 print_test_result (errorCount, argv[0]); 146 print_test_result (errorCount, argv[0]);
149 147
150 MHD_stop_daemon (d); 148 MHD_stop_daemon (d);
151 MHD__gnutls_global_deinit (); 149 gnutls_global_deinit ();
152 150
153 return errorCount != 0; 151 return errorCount != 0;
154} 152}
diff --git a/src/testcurl/https/tls_daemon_options_test.c b/src/testcurl/https/tls_daemon_options_test.c
index d7b29b08..e7d07964 100644
--- a/src/testcurl/https/tls_daemon_options_test.c
+++ b/src/testcurl/https/tls_daemon_options_test.c
@@ -28,8 +28,6 @@
28#include "microhttpd.h" 28#include "microhttpd.h"
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <limits.h> 30#include <limits.h>
31#include "gnutls.h"
32
33#include "tls_test_common.h" 31#include "tls_test_common.h"
34 32
35extern const char srv_key_pem[]; 33extern const char srv_key_pem[];
@@ -106,17 +104,17 @@ main (int argc, char *const *argv)
106 return -1; 104 return -1;
107 } 105 }
108 106
109 int p_ssl3[] = { MHD_GNUTLS_PROTOCOL_SSL3, 0 }; 107 int p_ssl3[] = { GNUTLS_SSL3, 0 };
110 int p_tls[] = { MHD_GNUTLS_PROTOCOL_TLS1_2, 108 int p_tls[] = { GNUTLS_TLS1_2,
111 MHD_GNUTLS_PROTOCOL_TLS1_1, 109 GNUTLS_TLS1_1,
112 MHD_GNUTLS_PROTOCOL_TLS1_0, 0 110 GNUTLS_TLS1_0, 0
113 }; 111 };
114 112
115 struct CipherDef ciphers[] = { 113 struct CipherDef ciphers[] = {
116 {{MHD_GNUTLS_CIPHER_AES_128_CBC, 0}, "AES128-SHA"}, 114 {{GNUTLS_CIPHER_AES_128_CBC, 0}, "AES128-SHA"},
117 {{MHD_GNUTLS_CIPHER_ARCFOUR_128, 0}, "RC4-SHA"}, 115 {{GNUTLS_CIPHER_ARCFOUR_128, 0}, "RC4-SHA"},
118 {{MHD_GNUTLS_CIPHER_3DES_CBC, 0}, "3DES-SHA"}, 116 {{GNUTLS_CIPHER_3DES_CBC, 0}, "3DES-SHA"},
119 {{MHD_GNUTLS_CIPHER_AES_256_CBC, 0}, "AES256-SHA"}, 117 {{GNUTLS_CIPHER_AES_256_CBC, 0}, "AES256-SHA"},
120 {{0, 0}, NULL} 118 {{0, 0}, NULL}
121 }; 119 };
122 fprintf (stderr, "SHA/TLS tests:\n"); 120 fprintf (stderr, "SHA/TLS tests:\n");
diff --git a/src/testcurl/https/tls_extension_test.c b/src/testcurl/https/tls_extension_test.c
index 84ed374f..e3b95299 100644
--- a/src/testcurl/https/tls_extension_test.c
+++ b/src/testcurl/https/tls_extension_test.c
@@ -27,19 +27,9 @@
27 27
28#include "platform.h" 28#include "platform.h"
29#include "microhttpd.h" 29#include "microhttpd.h"
30#include "gnutls_int.h"
31#include "gnutls_handshake.h" // MHD_gtls_send_handshake
32#include "gnutls_num.h" // MHD_gtls_write_x
33#include "common.h" // MHD_gtls_version_x
34
35
36#include "tls_test_common.h" 30#include "tls_test_common.h"
37#define MAX_EXT_DATA_LENGTH 256 31#define MAX_EXT_DATA_LENGTH 256
38 32
39extern int
40MHD__gnutls_copy_ciphersuites (MHD_gtls_session_t session,
41 opaque * ret_data, size_t ret_data_size);
42
43extern const char srv_key_pem[]; 33extern const char srv_key_pem[];
44extern const char srv_self_signed_cert_pem[]; 34extern const char srv_self_signed_cert_pem[];
45 35
@@ -53,7 +43,7 @@ extern const char srv_self_signed_cert_pem[];
53 * @return 0 on successful test completion, -1 otherwise 43 * @return 0 on successful test completion, -1 otherwise
54 */ 44 */
55static int 45static int
56test_hello_extension (MHD_gtls_session_t session, extensions_t exten_t, 46test_hello_extension (gnutls_session_t session, extensions_t exten_t,
57 int ext_count, int ext_length) 47 int ext_count, int ext_length)
58{ 48{
59 int i, sd, ret = 0, pos = 0; 49 int i, sd, ret = 0, pos = 0;
@@ -117,7 +107,7 @@ test_hello_extension (MHD_gtls_session_t session, extensions_t exten_t,
117 107
118 /* generate session client random */ 108 /* generate session client random */
119 memset (session->security_parameters.client_random, 0, TLS_RANDOM_SIZE); 109 memset (session->security_parameters.client_random, 0, TLS_RANDOM_SIZE);
120 MHD_gtls_write_uint32 (time (NULL), rnd); 110 gnutls_write_uint32 (time (NULL), rnd);
121 if (GC_OK != MHD_gc_nonce ((char *) &rnd[4], TLS_RANDOM_SIZE - 4)) abort (); 111 if (GC_OK != MHD_gc_nonce ((char *) &rnd[4], TLS_RANDOM_SIZE - 4)) abort ();
122 memcpy (session->security_parameters.client_random, rnd, TLS_RANDOM_SIZE); 112 memcpy (session->security_parameters.client_random, rnd, TLS_RANDOM_SIZE);
123 memcpy (&data[pos], rnd, TLS_RANDOM_SIZE); 113 memcpy (&data[pos], rnd, TLS_RANDOM_SIZE);
@@ -144,14 +134,14 @@ test_hello_extension (MHD_gtls_session_t session, extensions_t exten_t,
144 pos += 2; 134 pos += 2;
145 135
146 /* set extensions length = 2 type bytes + 2 length bytes + extension length */ 136 /* set extensions length = 2 type bytes + 2 length bytes + extension length */
147 MHD_gtls_write_uint16 (exten_data_len, &data[pos]); 137 gnutls_write_uint16 (exten_data_len, &data[pos]);
148 pos += 2; 138 pos += 2;
149 for (i = 0; i < ext_count; ++i) 139 for (i = 0; i < ext_count; ++i)
150 { 140 {
151 /* write extension type */ 141 /* write extension type */
152 MHD_gtls_write_uint16 (exten_t, &data[pos]); 142 gnutls_write_uint16 (exten_t, &data[pos]);
153 pos += 2; 143 pos += 2;
154 MHD_gtls_write_uint16 (ext_length, &data[pos]); 144 gnutls_write_uint16 (ext_length, &data[pos]);
155 pos += 2; 145 pos += 2;
156 /* we might want to generate random data here */ 146 /* we might want to generate random data here */
157 memset (&data[pos], 0, ext_length); 147 memset (&data[pos], 0, ext_length);
@@ -165,7 +155,7 @@ test_hello_extension (MHD_gtls_session_t session, extensions_t exten_t,
165 goto cleanup; 155 goto cleanup;
166 } 156 }
167 157
168 MHD__gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) (long) sd); 158 gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) (long) sd);
169 159
170 if (gen_test_file_url (url, DEAMON_TEST_PORT)) 160 if (gen_test_file_url (url, DEAMON_TEST_PORT))
171 { 161 {
@@ -174,15 +164,15 @@ test_hello_extension (MHD_gtls_session_t session, extensions_t exten_t,
174 } 164 }
175 165
176 /* this should crash the server */ 166 /* this should crash the server */
177 ret = MHD_gtls_send_handshake (session, data, datalen, 167 ret = gnutls_send_handshake (session, data, datalen,
178 GNUTLS_HANDSHAKE_CLIENT_HELLO); 168 GNUTLS_HANDSHAKE_CLIENT_HELLO);
179 169
180 /* advance to STATE2 */ 170 /* advance to STATE2 */
181 session->internals.handshake_state = STATE2; 171 session->internals.handshake_state = STATE2;
182 ret = MHD__gnutls_handshake (session); 172 ret = gnutls_handshake (session);
183 ret = MHD__gnutls_bye (session, GNUTLS_SHUT_WR); 173 ret = gnutls_bye (session, GNUTLS_SHUT_WR);
184 174
185 MHD_gnutls_free (data); 175 gnutls_free (data);
186 176
187 /* make sure daemon is still functioning */ 177 /* make sure daemon is still functioning */
188 if (CURLE_OK != send_curl_req (url, &cbc, "AES128-SHA", 178 if (CURLE_OK != send_curl_req (url, &cbc, "AES128-SHA",
@@ -195,7 +185,7 @@ test_hello_extension (MHD_gtls_session_t session, extensions_t exten_t,
195cleanup: 185cleanup:
196 if (sd != -1) 186 if (sd != -1)
197 close (sd); 187 close (sd);
198 MHD_gnutls_free (cbc.buf); 188 gnutls_free (cbc.buf);
199 return ret; 189 return ret;
200} 190}
201 191
@@ -205,10 +195,10 @@ main (int argc, char *const *argv)
205 int i, errorCount = 0; 195 int i, errorCount = 0;
206 FILE *test_fd; 196 FILE *test_fd;
207 struct MHD_Daemon *d; 197 struct MHD_Daemon *d;
208 MHD_gtls_session_t session; 198 gnutls_session_t session;
209 MHD_gnutls_datum_t key; 199 gnutls_datum_t key;
210 MHD_gnutls_datum_t cert; 200 gnutls_datum_t cert;
211 MHD_gtls_cert_credentials_t xcred; 201 gnutls_certificate_credentials_t xcred;
212 202
213 int ext_arr[] = { GNUTLS_EXTENSION_SERVER_NAME, 203 int ext_arr[] = { GNUTLS_EXTENSION_SERVER_NAME,
214 -1 204 -1
diff --git a/src/testcurl/https/tls_multi_thread_mode_test.c b/src/testcurl/https/tls_multi_thread_mode_test.c
index 602a7175..04049623 100644
--- a/src/testcurl/https/tls_multi_thread_mode_test.c
+++ b/src/testcurl/https/tls_multi_thread_mode_test.c
@@ -29,13 +29,11 @@
29 29
30#include "platform.h" 30#include "platform.h"
31#include "microhttpd.h" 31#include "microhttpd.h"
32
33#include <sys/stat.h> 32#include <sys/stat.h>
34#include <limits.h> 33#include <limits.h>
35#include "gnutls.h"
36#include <curl/curl.h> 34#include <curl/curl.h>
37
38#include "tls_test_common.h" 35#include "tls_test_common.h"
36
39extern const char srv_key_pem[]; 37extern const char srv_key_pem[];
40extern const char srv_self_signed_cert_pem[]; 38extern const char srv_self_signed_cert_pem[];
41 39
diff --git a/src/testcurl/https/tls_session_time_out_test.c b/src/testcurl/https/tls_session_time_out_test.c
index 7609160d..88e3cadc 100644
--- a/src/testcurl/https/tls_session_time_out_test.c
+++ b/src/testcurl/https/tls_session_time_out_test.c
@@ -28,11 +28,8 @@
28#include "platform.h" 28#include "platform.h"
29#include "microhttpd.h" 29#include "microhttpd.h"
30#include "internal.h" 30#include "internal.h"
31#include "gnutls_int.h"
32#include "gnutls_datum.h"
33#include "gnutls_record.h"
34
35#include "tls_test_common.h" 31#include "tls_test_common.h"
32
36extern const char srv_key_pem[]; 33extern const char srv_key_pem[];
37extern const char srv_self_signed_cert_pem[]; 34extern const char srv_self_signed_cert_pem[];
38 35
@@ -41,51 +38,7 @@ static const int TIME_OUT = 3;
41char *http_get_req = "GET / HTTP/1.1\r\n\r\n"; 38char *http_get_req = "GET / HTTP/1.1\r\n\r\n";
42 39
43static int 40static int
44setup_timeout_test (MHD_gtls_session_t * session, 41test_tls_session_time_out (gnutls_session_t session)
45 MHD_gnutls_datum_t * key,
46 MHD_gnutls_datum_t * cert,
47 MHD_gtls_cert_credentials_t * xcred)
48{
49 int ret;
50
51 MHD__gnutls_certificate_allocate_credentials (xcred);
52
53 MHD_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc);
54 MHD_gtls_set_datum_m (cert, srv_self_signed_cert_pem,
55 strlen (srv_self_signed_cert_pem), &malloc);
56
57 MHD__gnutls_certificate_set_x509_key_mem (*xcred, cert, key,
58 GNUTLS_X509_FMT_PEM);
59
60 MHD__gnutls_init (session, GNUTLS_CLIENT);
61 ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", NULL);
62 if (ret < 0)
63 {
64 return -1;
65 }
66
67 MHD__gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
68 return 0;
69}
70
71static int
72teardown_timeout_test (MHD_gtls_session_t session,
73 MHD_gnutls_datum_t * key,
74 MHD_gnutls_datum_t * cert,
75 MHD_gtls_cert_credentials_t xcred)
76{
77
78 MHD_gtls_free_datum_m (key, free);
79 MHD_gtls_free_datum_m (cert, free);
80
81 MHD__gnutls_deinit (session);
82
83 MHD__gnutls_certificate_free_credentials (xcred);
84 return 0;
85}
86
87static int
88test_tls_session_time_out (MHD_gtls_session_t session)
89{ 42{
90 int sd, ret; 43 int sd, ret;
91 struct sockaddr_in sa; 44 struct sockaddr_in sa;
@@ -102,7 +55,7 @@ test_tls_session_time_out (MHD_gtls_session_t session)
102 sa.sin_port = htons (DEAMON_TEST_PORT); 55 sa.sin_port = htons (DEAMON_TEST_PORT);
103 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); 56 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr);
104 57
105 MHD__gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) (long) sd); 58 gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) (long) sd);
106 59
107 ret = connect (sd, &sa, sizeof (struct sockaddr_in)); 60 ret = connect (sd, &sa, sizeof (struct sockaddr_in));
108 61
@@ -112,7 +65,7 @@ test_tls_session_time_out (MHD_gtls_session_t session)
112 return -1; 65 return -1;
113 } 66 }
114 67
115 ret = MHD__gnutls_handshake (session); 68 ret = gnutls_handshake (session);
116 if (ret < 0) 69 if (ret < 0)
117 { 70 {
118 return -1; 71 return -1;
@@ -136,13 +89,13 @@ main (int argc, char *const *argv)
136{ 89{
137 int errorCount = 0;; 90 int errorCount = 0;;
138 struct MHD_Daemon *d; 91 struct MHD_Daemon *d;
139 MHD_gtls_session_t session; 92 gnutls_session_t session;
140 MHD_gnutls_datum_t key; 93 gnutls_datum_t key;
141 MHD_gnutls_datum_t cert; 94 gnutls_datum_t cert;
142 MHD_gtls_cert_credentials_t xcred; 95 gnutls_certificate_credentials_t xcred;
143 96
144 MHD__gnutls_global_init (); 97 gnutls_global_init ();
145 MHD_gtls_global_set_log_level (11); 98 gnutls_global_set_log_level (11);
146 99
147 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 100 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
148 MHD_USE_DEBUG, DEAMON_TEST_PORT, 101 MHD_USE_DEBUG, DEAMON_TEST_PORT,
@@ -158,14 +111,14 @@ main (int argc, char *const *argv)
158 return -1; 111 return -1;
159 } 112 }
160 113
161 setup_timeout_test (&session, &key, &cert, &xcred); 114 setup_session (&session, &key, &cert, &xcred);
162 errorCount += test_tls_session_time_out (session); 115 errorCount += test_tls_session_time_out (session);
163 teardown_timeout_test (session, &key, &cert, xcred); 116 teardown_session (session, &key, &cert, xcred);
164 117
165 print_test_result (errorCount, argv[0]); 118 print_test_result (errorCount, argv[0]);
166 119
167 MHD_stop_daemon (d); 120 MHD_stop_daemon (d);
168 MHD__gnutls_global_deinit (); 121 gnutls_global_deinit ();
169 122
170 return errorCount != 0; 123 return errorCount != 0;
171} 124}
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c
index ce794511..0d2acd4e 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -19,14 +19,12 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file tls_daemon_options_test.c 22 * @file tls_test_common.c
23 * @brief Common tls test functions 23 * @brief Common tls test functions
24 * @author Sagie Amir 24 * @author Sagie Amir
25 */ 25 */
26#include "tls_test_common.h" 26#include "tls_test_common.h"
27#include "tls_test_keys.h" 27#include "tls_test_keys.h"
28#include "gnutls.h"
29#include "gnutls_datum.h"
30 28
31const char test_file_data[] = "Hello World\n"; 29const char test_file_data[] = "Hello World\n";
32 30
@@ -344,46 +342,48 @@ teardown_testcase (struct MHD_Daemon *d)
344} 342}
345 343
346int 344int
347setup_session (MHD_gtls_session_t * session, 345setup_session (gnutls_session_t * session,
348 MHD_gnutls_datum_t * key, 346 gnutls_datum_t * key,
349 MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t * xcred) 347 gnutls_datum_t * cert,
348 gnutls_certificate_credentials_t * xcred)
350{ 349{
351 int ret; 350 int ret;
352 const char *err_pos; 351 const char *err_pos;
353 352
354 MHD__gnutls_certificate_allocate_credentials (xcred); 353 gnutls_certificate_allocate_credentials (xcred);
355 354 key->size = strlen (srv_key_pem);
356 MHD_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc); 355 key->data = malloc (key->size);
357 MHD_gtls_set_datum_m (cert, srv_self_signed_cert_pem, 356 memcpy (key->data, srv_key_pem, key->size);
358 strlen (srv_self_signed_cert_pem), &malloc); 357 cert->size = strlen (srv_self_signed_cert_pem);
359 358 cert->data = malloc (cert->size);
360 MHD__gnutls_certificate_set_x509_key_mem (*xcred, cert, key, 359 memcpy (cert->data, srv_self_signed_cert_pem, cert->size);
361 GNUTLS_X509_FMT_PEM); 360 gnutls_certificate_set_x509_key_mem (*xcred, cert, key,
362 361 GNUTLS_X509_FMT_PEM);
363 MHD__gnutls_init (session, GNUTLS_CLIENT); 362 gnutls_init (session, GNUTLS_CLIENT);
364 ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", &err_pos); 363 ret = gnutls_priority_set_direct (*session,
364 "NORMAL", &err_pos);
365 if (ret < 0) 365 if (ret < 0)
366 { 366 return -1;
367 return -1; 367 gnutls_credentials_set (*session,
368 } 368 GNUTLS_CRD_CERTIFICATE,
369 369 xcred);
370 MHD__gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
371 return 0; 370 return 0;
372} 371}
373 372
374int 373int
375teardown_session (MHD_gtls_session_t session, 374teardown_session (gnutls_session_t session,
376 MHD_gnutls_datum_t * key, 375 gnutls_datum_t * key,
377 MHD_gnutls_datum_t * cert, 376 gnutls_datum_t * cert,
378 MHD_gtls_cert_credentials_t xcred) 377 gnutls_certificate_credentials_t xcred)
379{ 378{
380 379 free (key->data);
381 MHD_gtls_free_datum_m (key, free); 380 key->data = NULL;
382 MHD_gtls_free_datum_m (cert, free); 381 key->size = 0;
383 382 free (cert->data);
384 MHD__gnutls_deinit (session); 383 cert->data = NULL;
385 384 cert->size = 0;
386 MHD__gnutls_certificate_free_credentials (xcred); 385 gnutls_deinit (session);
386 gnutls_certificate_free_credentials (xcred);
387 return 0; 387 return 0;
388} 388}
389 389
diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h
index 965614d1..140bbb90 100644
--- a/src/testcurl/https/tls_test_common.h
+++ b/src/testcurl/https/tls_test_common.h
@@ -26,7 +26,7 @@
26#include <curl/curl.h> 26#include <curl/curl.h>
27#include <sys/stat.h> 27#include <sys/stat.h>
28#include <limits.h> 28#include <limits.h>
29#include "gnutls.h" 29#include <gnutls/gnutls.h>
30 30
31/* this enables verbos CURL version checking */ 31/* this enables verbos CURL version checking */
32#define DEBUG_HTTPS_TEST 0 32#define DEBUG_HTTPS_TEST 0
@@ -99,16 +99,16 @@ setup_testcase (struct MHD_Daemon **d, int daemon_flags, va_list arg_list);
99void teardown_testcase (struct MHD_Daemon *d); 99void teardown_testcase (struct MHD_Daemon *d);
100 100
101int 101int
102setup_session (MHD_gtls_session_t * session, 102setup_session (gnutls_session_t * session,
103 MHD_gnutls_datum_t * key, 103 gnutls_datum_t * key,
104 MHD_gnutls_datum_t * cert, 104 gnutls_datum_t * cert,
105 MHD_gtls_cert_credentials_t * xcred); 105 gnutls_certificate_credentials_t * xcred);
106 106
107int 107int
108teardown_session (MHD_gtls_session_t session, 108teardown_session (gnutls_session_t session,
109 MHD_gnutls_datum_t * key, 109 gnutls_datum_t * key,
110 MHD_gnutls_datum_t * cert, 110 gnutls_datum_t * cert,
111 MHD_gtls_cert_credentials_t xcred); 111 gnutls_certificate_credentials_t xcred);
112 112
113int 113int
114test_wrap (char *test_name, int 114test_wrap (char *test_name, int
diff --git a/src/testcurl/https/tls_thread_mode_test.c b/src/testcurl/https/tls_thread_mode_test.c
index cf92a26d..fdf8840e 100644
--- a/src/testcurl/https/tls_thread_mode_test.c
+++ b/src/testcurl/https/tls_thread_mode_test.c
@@ -29,13 +29,11 @@
29 29
30#include "platform.h" 30#include "platform.h"
31#include "microhttpd.h" 31#include "microhttpd.h"
32
33#include <sys/stat.h> 32#include <sys/stat.h>
34#include <limits.h> 33#include <limits.h>
35#include "gnutls.h"
36#include <curl/curl.h> 34#include <curl/curl.h>
37
38#include "tls_test_common.h" 35#include "tls_test_common.h"
36
39extern const char srv_key_pem[]; 37extern const char srv_key_pem[];
40extern const char srv_self_signed_cert_pem[]; 38extern const char srv_self_signed_cert_pem[];
41 39