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.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/testcurl/https/test_tls_authentication.c b/src/testcurl/https/test_tls_authentication.c
new file mode 100644
index 00000000..cb80475c
--- /dev/null
+++ b/src/testcurl/https/test_tls_authentication.c
@@ -0,0 +1,103 @@
1/*
2 This file is part of libmicrohttpd
3 (C) 2007 Christian Grothoff
4
5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 libmicrohttpd is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with libmicrohttpd; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20
21/**
22 * @file tls_authentication_test.c
23 * @brief Testcase for libmicrohttpd HTTPS GET operations
24 * @author Sagie Amir
25 */
26
27#include "platform.h"
28#include "microhttpd.h"
29#include <curl/curl.h>
30#include <limits.h>
31#include <sys/stat.h>
32
33#include "tls_test_common.h"
34
35extern int curl_check_version (const char *req_version, ...);
36extern const char test_file_data[];
37
38extern const char ca_key_pem[];
39extern const char ca_cert_pem[];
40extern const char srv_signed_cert_pem[];
41extern const char srv_signed_key_pem[];
42
43
44
45/* perform a HTTP GET request via SSL/TLS */
46static int
47test_secure_get (void * cls, char *cipher_suite, int proto_version)
48{
49 int ret;
50 struct MHD_Daemon *d;
51
52 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
53 MHD_USE_DEBUG, DEAMON_TEST_PORT,
54 NULL, NULL, &http_ahc, NULL,
55 MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem,
56 MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem,
57 MHD_OPTION_END);
58
59 if (d == NULL)
60 {
61 fprintf (stderr, MHD_E_SERVER_INIT);
62 return -1;
63 }
64
65 ret = test_daemon_get (NULL, cipher_suite, proto_version, DEAMON_TEST_PORT, 0);
66
67 MHD_stop_daemon (d);
68 return ret;
69}
70
71
72int
73main (int argc, char *const *argv)
74{
75 unsigned int errorCount = 0;
76
77 if (setup_ca_cert () == NULL)
78 {
79 fprintf (stderr, MHD_E_TEST_FILE_CREAT);
80 return -1;
81 }
82
83 if (0 != curl_global_init (CURL_GLOBAL_ALL))
84 {
85 fprintf (stderr, "Error (code: %u)\n", errorCount);
86 return -1;
87 }
88
89 char *aes256_sha = "AES256-SHA";
90 if (curl_uses_nss_ssl() == 0)
91 {
92 aes256_sha = "rsa_aes_256_sha";
93 }
94
95 errorCount +=
96 test_secure_get (NULL, aes256_sha, CURL_SSLVERSION_TLSv1);
97
98 print_test_result (errorCount, argv[0]);
99
100 curl_global_cleanup ();
101 remove (ca_cert_file_name);
102 return errorCount != 0;
103}