X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tests%2Fclient.c;h=028189a24d44843c932955c5bcf0b6a6addc5975;hb=23787d573fd2e4f31c1205f17c5d90fd5516a3fc;hp=51429107c40c83c14c54bad8e50779721256ee99;hpb=72f63c90dd442da6139399d3a3b7fd574d209e08;p=tlsproxy%2Ftlsproxy.git diff --git a/tests/client.c b/tests/client.c index 5142910..028189a 100644 --- a/tests/client.c +++ b/tests/client.c @@ -39,6 +39,12 @@ static int fdopen_read_write(int socket, FILE **read_fd, FILE **write_fd); static int connect_to_host(const char *hostname, const char *port); static int read_http_request(FILE *client_fd, char *request, size_t length); +#if 0 +static void log_function_gnutls(int level, const char *string) { + (void)level; + fprintf(stderr, " => %s", string); +} +#endif int main (int argc, char *argv[]) { int result, response; @@ -65,6 +71,11 @@ int main (int argc, char *argv[]) { gnutls_global_init(); gnutls_certificate_allocate_credentials(&xcred); +#if 0 + gnutls_global_set_log_level(10); + gnutls_global_set_log_function(log_function_gnutls); +#endif + gnutls_certificate_set_x509_trust_file(xcred, argv[1], GNUTLS_X509_FMT_PEM); @@ -153,6 +164,11 @@ int main (int argc, char *argv[]) { gnutls_x509_crt_deinit(cert); + /* Send a bogus request to the server. Otherwise recent gnutls-serv won't + * terminate the connection when gnutls_bye() is used. */ + gnutls_record_send(session, "GET / HTTP/1.0\r\n\r\n", + strlen("GET / HTTP/1.0\r\n\r\n")); + gnutls_bye(session, GNUTLS_SHUT_RDWR); fclose(fd_read); fclose(fd_write);