[glib-networking/mcatanzaro/tls1.2: 39/41] Always call complete_handshake() even if handshake failed



commit 9d063efe243514bf2af38e20cf0b2544f349aa17
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Tue Sep 24 14:28:06 2019 -0500

    Always call complete_handshake() even if handshake failed
    
    Otherwise we might not notify accepted-cas as the tests expect. This is
    really minor, but good to do since they could have changed even though
    the handshake failed.
    
    Same for negotiated-protocol.

 tls/base/gtlsconnection-base.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index 6b6b6f2..b6c0a55 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -1497,13 +1497,6 @@ finish_handshake (GTlsConnectionBase  *tls,
           g_mutex_unlock (&priv->verify_certificate_mutex);
         }
 
-      if (tls_class->complete_handshake)
-        tls_class->complete_handshake (tls, &priv->negotiated_protocol, &my_error);
-
-      if (g_strcmp0 (original_negotiated_protocol, priv->negotiated_protocol) != 0)
-        g_object_notify (G_OBJECT (tls), "negotiated-protocol");
-      g_free (original_negotiated_protocol);
-
       /* FIXME: Return an error from the handshake thread instead. */
       if (priv->peer_certificate && !priv->peer_certificate_accepted)
         {
@@ -1512,6 +1505,16 @@ finish_handshake (GTlsConnectionBase  *tls,
         }
     }
 
+  if (tls_class->complete_handshake)
+    {
+      /* If we already have an error, ignore further errors. */
+      tls_class->complete_handshake (tls, &priv->negotiated_protocol, my_error ? NULL : &my_error);
+
+      if (g_strcmp0 (original_negotiated_protocol, priv->negotiated_protocol) != 0)
+        g_object_notify (G_OBJECT (tls), "negotiated-protocol");
+    }
+  g_free (original_negotiated_protocol);
+
   if (my_error && priv->started_handshake)
     priv->handshake_error = g_error_copy (my_error);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]