diff options
Diffstat (limited to 'src/microhttpd/test_upgrade_ssl.c')
-rw-r--r-- | src/microhttpd/test_upgrade_ssl.c | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/src/microhttpd/test_upgrade_ssl.c b/src/microhttpd/test_upgrade_ssl.c index 145c733b..07031cff 100644 --- a/src/microhttpd/test_upgrade_ssl.c +++ b/src/microhttpd/test_upgrade_ssl.c | |||
@@ -47,6 +47,15 @@ | |||
47 | #include "../testcurl/https/tls_test_keys.h" | 47 | #include "../testcurl/https/tls_test_keys.h" |
48 | 48 | ||
49 | 49 | ||
50 | enum tls_cli_tool | ||
51 | { | ||
52 | TLS_CLI_NO_TOOL = 0, | ||
53 | TLS_CLI_GNUTLS, | ||
54 | TLS_CLI_OPENSSL | ||
55 | }; | ||
56 | |||
57 | enum tls_cli_tool use_tool; | ||
58 | |||
50 | /** | 59 | /** |
51 | * Fork child that connects via OpenSSL to our @a port. Allows us to | 60 | * Fork child that connects via OpenSSL to our @a port. Allows us to |
52 | * talk to our port over a socket in @a sp without having to worry | 61 | * talk to our port over a socket in @a sp without having to worry |
@@ -81,17 +90,35 @@ openssl_connect (int *sock, | |||
81 | dup2 (sp[0], 0); | 90 | dup2 (sp[0], 0); |
82 | dup2 (sp[0], 1); | 91 | dup2 (sp[0], 1); |
83 | MHD_socket_close_chk_ (sp[0]); | 92 | MHD_socket_close_chk_ (sp[0]); |
84 | sprintf (destination, | 93 | if (TLS_CLI_GNUTLS == use_tool) |
85 | "localhost:%u", | 94 | { |
86 | (unsigned int) port); | 95 | snprintf (destination, |
87 | execlp ("openssl", | 96 | sizeof(destination), |
88 | "openssl", | 97 | "%u", |
89 | "s_client", | 98 | (unsigned int) port); |
90 | "-connect", | 99 | execlp ("gnutls-cli", |
91 | destination, | 100 | "gnutls-cli", |
92 | "-verify", | 101 | "--insecure", |
93 | "0", | 102 | "-p", |
94 | (char *) NULL); | 103 | destination, |
104 | "localhost", | ||
105 | (char *) NULL); | ||
106 | } | ||
107 | else if (TLS_CLI_OPENSSL == use_tool) | ||
108 | { | ||
109 | snprintf (destination, | ||
110 | sizeof(destination), | ||
111 | "localhost:%u", | ||
112 | (unsigned int) port); | ||
113 | execlp ("openssl", | ||
114 | "openssl", | ||
115 | "s_client", | ||
116 | "-connect", | ||
117 | destination, | ||
118 | "-verify", | ||
119 | "0", | ||
120 | (char *) NULL); | ||
121 | } | ||
95 | _exit (1); | 122 | _exit (1); |
96 | } | 123 | } |
97 | 124 | ||
@@ -160,8 +187,13 @@ main (int argc, | |||
160 | { | 187 | { |
161 | int error_count = 0; | 188 | int error_count = 0; |
162 | 189 | ||
163 | if (0 != system ("openssl version 1> /dev/null")) | 190 | use_tool = TLS_CLI_NO_TOOL; |
164 | return 77; /* openssl not available, can't run the test */ | 191 | if (0 == system ("gnutls-cli --version 1> /dev/null")) |
192 | use_tool = TLS_CLI_GNUTLS; | ||
193 | else if (0 != system ("openssl version 1> /dev/null")) | ||
194 | use_tool = TLS_CLI_OPENSSL; | ||
195 | else | ||
196 | return 77; /* not possible to test */ | ||
165 | 197 | ||
166 | /* try external select */ | 198 | /* try external select */ |
167 | error_count += test_upgrade (0, | 199 | error_count += test_upgrade (0, |