aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/https/tls_alert_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/https/tls_alert_test.c')
-rw-r--r--src/testcurl/https/tls_alert_test.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/testcurl/https/tls_alert_test.c b/src/testcurl/https/tls_alert_test.c
index 34ab883f..238150e6 100644
--- a/src/testcurl/https/tls_alert_test.c
+++ b/src/testcurl/https/tls_alert_test.c
@@ -57,45 +57,45 @@ http_ahc (void *cls, struct MHD_Connection *connection,
57} 57}
58 58
59static int 59static int
60setup (mhd_gtls_session_t * session, 60setup (MHD_gtls_session_t * session,
61 gnutls_datum_t * key, 61 MHD_gnutls_datum_t * key,
62 gnutls_datum_t * cert, mhd_gtls_cert_credentials_t * xcred) 62 MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t * xcred)
63{ 63{
64 int ret; 64 int ret;
65 const char **err_pos; 65 const char **err_pos;
66 66
67 MHD_gnutls_certificate_allocate_credentials (xcred); 67 MHD__gnutls_certificate_allocate_credentials (xcred);
68 68
69 mhd_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc); 69 MHD_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc);
70 mhd_gtls_set_datum_m (cert, srv_self_signed_cert_pem, 70 MHD_gtls_set_datum_m (cert, srv_self_signed_cert_pem,
71 strlen (srv_self_signed_cert_pem), &malloc); 71 strlen (srv_self_signed_cert_pem), &malloc);
72 72
73 MHD_gnutls_certificate_set_x509_key_mem (*xcred, cert, key, 73 MHD__gnutls_certificate_set_x509_key_mem (*xcred, cert, key,
74 GNUTLS_X509_FMT_PEM); 74 GNUTLS_X509_FMT_PEM);
75 75
76 MHD_gnutls_init (session, GNUTLS_CLIENT); 76 MHD__gnutls_init (session, GNUTLS_CLIENT);
77 ret = MHD_gnutls_priority_set_direct (*session, "NORMAL", err_pos); 77 ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", err_pos);
78 if (ret < 0) 78 if (ret < 0)
79 { 79 {
80 return -1; 80 return -1;
81 } 81 }
82 82
83 MHD_gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred); 83 MHD__gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
84 return 0; 84 return 0;
85} 85}
86 86
87static int 87static int
88teardown (mhd_gtls_session_t session, 88teardown (MHD_gtls_session_t session,
89 gnutls_datum_t * key, 89 MHD_gnutls_datum_t * key,
90 gnutls_datum_t * cert, mhd_gtls_cert_credentials_t xcred) 90 MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t xcred)
91{ 91{
92 92
93 mhd_gtls_free_datum_m (key, free); 93 MHD_gtls_free_datum_m (key, free);
94 mhd_gtls_free_datum_m (cert, free); 94 MHD_gtls_free_datum_m (cert, free);
95 95
96 MHD_gnutls_deinit (session); 96 MHD__gnutls_deinit (session);
97 97
98 MHD_gnutls_certificate_free_credentials (xcred); 98 MHD__gnutls_certificate_free_credentials (xcred);
99 return 0; 99 return 0;
100} 100}
101 101
@@ -106,7 +106,7 @@ teardown (mhd_gtls_session_t session,
106 * @param session: an initialized TLS session 106 * @param session: an initialized TLS session
107 */ 107 */
108static int 108static int
109test_alert_close_notify (mhd_gtls_session_t session) 109test_alert_close_notify (MHD_gtls_session_t session)
110{ 110{
111 int sd, ret; 111 int sd, ret;
112 struct sockaddr_in sa; 112 struct sockaddr_in sa;
@@ -117,7 +117,7 @@ test_alert_close_notify (mhd_gtls_session_t session)
117 sa.sin_port = htons (42433); 117 sa.sin_port = htons (42433);
118 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); 118 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr);
119 119
120 MHD_gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd); 120 MHD__gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) sd);
121 121
122 ret = connect (sd, &sa, sizeof (struct sockaddr_in)); 122 ret = connect (sd, &sa, sizeof (struct sockaddr_in));
123 123
@@ -127,16 +127,16 @@ test_alert_close_notify (mhd_gtls_session_t session)
127 return -1; 127 return -1;
128 } 128 }
129 129
130 ret = MHD_gnutls_handshake (session); 130 ret = MHD__gnutls_handshake (session);
131 if (ret < 0) 131 if (ret < 0)
132 { 132 {
133 return -1; 133 return -1;
134 } 134 }
135 135
136 MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL, GNUTLS_A_CLOSE_NOTIFY); 136 MHD__gnutls_alert_send (session, GNUTLS_AL_FATAL, GNUTLS_A_CLOSE_NOTIFY);
137 137
138 /* check server responds with a 'close-notify' */ 138 /* check server responds with a 'close-notify' */
139 mhd_gtls_recv_int (session, GNUTLS_ALERT, GNUTLS_HANDSHAKE_FINISHED, 0, 0); 139 MHD_gtls_recv_int (session, GNUTLS_ALERT, GNUTLS_HANDSHAKE_FINISHED, 0, 0);
140 140
141 close (sd); 141 close (sd);
142 /* CLOSE_NOTIFY */ 142 /* CLOSE_NOTIFY */
@@ -155,7 +155,7 @@ test_alert_close_notify (mhd_gtls_session_t session)
155 * @param session: an initialized TLS session 155 * @param session: an initialized TLS session
156 */ 156 */
157static int 157static int
158test_alert_unexpected_message (mhd_gtls_session_t session) 158test_alert_unexpected_message (MHD_gtls_session_t session)
159{ 159{
160 int sd, ret; 160 int sd, ret;
161 struct sockaddr_in sa; 161 struct sockaddr_in sa;
@@ -166,8 +166,8 @@ test_alert_unexpected_message (mhd_gtls_session_t session)
166 sa.sin_port = htons (42433); 166 sa.sin_port = htons (42433);
167 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); 167 inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr);
168 168
169 MHD_gnutls_transport_set_ptr (session, 169 MHD__gnutls_transport_set_ptr (session,
170 (gnutls_transport_ptr_t) ((void *) sd)); 170 (MHD_gnutls_transport_ptr_t) ((void *) sd));
171 171
172 ret = connect (sd, &sa, sizeof (struct sockaddr_in)); 172 ret = connect (sd, &sa, sizeof (struct sockaddr_in));
173 173
@@ -177,13 +177,13 @@ test_alert_unexpected_message (mhd_gtls_session_t session)
177 return -1; 177 return -1;
178 } 178 }
179 179
180 ret = MHD_gnutls_handshake (session); 180 ret = MHD__gnutls_handshake (session);
181 if (ret < 0) 181 if (ret < 0)
182 { 182 {
183 return -1; 183 return -1;
184 } 184 }
185 185
186 MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL, 186 MHD__gnutls_alert_send (session, GNUTLS_AL_FATAL,
187 GNUTLS_A_UNEXPECTED_MESSAGE); 187 GNUTLS_A_UNEXPECTED_MESSAGE);
188 usleep (100); 188 usleep (100);
189 189
@@ -202,12 +202,12 @@ main (int argc, char *const *argv)
202{ 202{
203 int errorCount = 0;; 203 int errorCount = 0;;
204 struct MHD_Daemon *d; 204 struct MHD_Daemon *d;
205 mhd_gtls_session_t session; 205 MHD_gtls_session_t session;
206 gnutls_datum_t key; 206 MHD_gnutls_datum_t key;
207 gnutls_datum_t cert; 207 MHD_gnutls_datum_t cert;
208 mhd_gtls_cert_credentials_t xcred; 208 MHD_gtls_cert_credentials_t xcred;
209 209
210 MHD_gnutls_global_init (); 210 MHD__gnutls_global_init ();
211 MHD_gtls_global_set_log_level (11); 211 MHD_gtls_global_set_log_level (11);
212 212
213 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 213 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
@@ -235,7 +235,7 @@ main (int argc, char *const *argv)
235 fprintf (stderr, "Failed test: %s.\n", argv[0]); 235 fprintf (stderr, "Failed test: %s.\n", argv[0]);
236 236
237 MHD_stop_daemon (d); 237 MHD_stop_daemon (d);
238 MHD_gnutls_global_deinit (); 238 MHD__gnutls_global_deinit ();
239 239
240 return errorCount != 0; 240 return errorCount != 0;
241} 241}