]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/commitdiff
Fix test-suite for recent gnutls-serv.
authorSimon Ruderich <simon@ruderich.org>
Tue, 6 Aug 2013 04:15:47 +0000 (06:15 +0200)
committerSimon Ruderich <simon@ruderich.org>
Tue, 6 Aug 2013 04:15:47 +0000 (06:15 +0200)
src/connection.c
tests/client.c

index 170302c9fdaf9894267c91da2ebd4934a27a6843..3602842b596486daef1ef8cbb07c030b3f28575b 100644 (file)
@@ -313,7 +313,16 @@ out:
     /* Close TLS sessions if necessary. Use GNUTLS_SHUT_RDWR so the data is
      * reliable transmitted. */
     if (server_session_started) {
     /* Close TLS sessions if necessary. Use GNUTLS_SHUT_RDWR so the data is
      * reliable transmitted. */
     if (server_session_started) {
-        gnutls_bye(server_session, GNUTLS_SHUT_RDWR);
+        /* Recent gnutls-serv (used in the test-suite) won't terminate the
+         * connection when gnutls_bye(session, GNUTLS_SHUT_RDWR) is used
+         * before any other data was received. If the validation failed just
+         * close the connection without waiting for data, we won't read it
+         * anyway.
+         *
+         * For verified connections GNUTLS_SHUT_RDWR is important or we might
+         * lose data. */
+        gnutls_bye(server_session, validation_failed ? GNUTLS_SHUT_WR
+                                                     : GNUTLS_SHUT_RDWR);
     }
     if (client_session_started) {
         gnutls_bye(client_session, GNUTLS_SHUT_RDWR);
     }
     if (client_session_started) {
         gnutls_bye(client_session, GNUTLS_SHUT_RDWR);
index 51429107c40c83c14c54bad8e50779721256ee99..41ddf5d1a3a2573de54a85e901f533ca42e08dd1 100644 (file)
@@ -153,6 +153,11 @@ int main (int argc, char *argv[]) {
 
     gnutls_x509_crt_deinit(cert);
 
 
     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);
     gnutls_bye(session, GNUTLS_SHUT_RDWR);
     fclose(fd_read);
     fclose(fd_write);