[glib-networking/mcatanzaro/tls-thread] Progress



commit 454dccf349b5303be49f21416ae6e2ed99469783
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Dec 29 10:43:19 2019 -0600

    Progress

 tls/base/gtlsoperationsthread-base.c     | 14 ++++++++++++--
 tls/base/gtlsoperationsthread-base.h     |  3 ++-
 tls/gnutls/gtlscertificate-gnutls.c      | 16 ++++++++--------
 tls/gnutls/gtlscertificate-gnutls.h      |  4 ++--
 tls/gnutls/gtlsoperationsthread-gnutls.c | 30 +++++++++++++++---------------
 5 files changed, 39 insertions(+), 28 deletions(-)
---
diff --git a/tls/base/gtlsoperationsthread-base.c b/tls/base/gtlsoperationsthread-base.c
index 0168a13..bb12fdf 100644
--- a/tls/base/gtlsoperationsthread-base.c
+++ b/tls/base/gtlsoperationsthread-base.c
@@ -222,13 +222,16 @@ g_tls_operations_thread_base_take_interaction_error (GTlsOperationsThreadBase *s
 }
 
 gboolean
-g_tls_operations_thread_base_request_certificate (GTlsOperationsThreadBase *self,
-                                                  GCancellable             *cancellable)
+g_tls_operations_thread_base_request_certificate (GTlsOperationsThreadBase  *self,
+                                                  GCancellable              *cancellable,
+                                                  GTlsCertificate          **own_certificate)
 {
   GTlsOperationsThreadBasePrivate *priv = g_tls_operations_thread_base_get_instance_private (self);
   GTlsInteractionResult res = G_TLS_INTERACTION_UNHANDLED;
+  GTlsCertificate *cert;
 
   g_mutex_lock (&priv->mutex);
+
   g_clear_error (&priv->interaction_error);
   if (priv->interaction)
     {
@@ -238,6 +241,13 @@ g_tls_operations_thread_base_request_certificate (GTlsOperationsThreadBase *self
                                                           cancellable,
                                                           &priv->interaction_error);
     }
+
+  cert = g_tls_connection_get_certificate (G_TLS_CONNECTION (priv->connection));
+  if (cert)
+    *own_certificate = G_TLS_OPERATIONS_THREAD_BASE_GET_CLASS (self)->copy_certificate (self, cert);
+  else
+    *own_certificate = NULL;
+
   g_mutex_unlock (&priv->mutex);
 
   return res != G_TLS_INTERACTION_FAILED;
diff --git a/tls/base/gtlsoperationsthread-base.h b/tls/base/gtlsoperationsthread-base.h
index 7d390fa..4f04f9c 100644
--- a/tls/base/gtlsoperationsthread-base.h
+++ b/tls/base/gtlsoperationsthread-base.h
@@ -108,7 +108,8 @@ GTlsInteraction          *g_tls_operations_thread_base_ref_interaction
 GError                   *g_tls_operations_thread_base_take_interaction_error    (GTlsOperationsThreadBase   
*self);
 
 gboolean                  g_tls_operations_thread_base_request_certificate       (GTlsOperationsThreadBase   
*self,
-                                                                                  GCancellable               
*cancellable);
+                                                                                  GCancellable               
*cancellable,
+                                                                                  GTlsCertificate           
**own_certificate);
 
 void                      g_tls_operations_thread_base_set_is_missing_requested_client_certificate
                                                                                  (GTlsOperationsThreadBase  
*self);
diff --git a/tls/gnutls/gtlscertificate-gnutls.c b/tls/gnutls/gtlscertificate-gnutls.c
index c812231..1fcc771 100644
--- a/tls/gnutls/gtlscertificate-gnutls.c
+++ b/tls/gnutls/gtlscertificate-gnutls.c
@@ -470,11 +470,11 @@ g_tls_certificate_gnutls_has_key (GTlsCertificateGnutls *gnutls)
 }
 
 void
-g_tls_certificate_gnutls_copy  (GTlsCertificateGnutls  *gnutls,
-                                const gchar            *interaction_id,
-                                gnutls_pcert_st       **pcert,
-                                unsigned int           *pcert_length,
-                                gnutls_privkey_t       *pkey)
+g_tls_certificate_gnutls_copy_internals (GTlsCertificateGnutls  *gnutls,
+                                         const gchar            *interaction_id,
+                                         gnutls_pcert_st       **pcert,
+                                         unsigned int           *pcert_length,
+                                         gnutls_privkey_t       *pkey)
 {
   GTlsCertificateGnutls *chain;
   guint num_certs = 0;
@@ -544,9 +544,9 @@ g_tls_certificate_gnutls_copy  (GTlsCertificateGnutls  *gnutls,
 }
 
 void
-g_tls_certificate_gnutls_copy_free (gnutls_pcert_st  *pcert,
-                                    unsigned int      pcert_length,
-                                    gnutls_privkey_t  pkey)
+g_tls_certificate_gnutls_internals_free (gnutls_pcert_st  *pcert,
+                                         unsigned int      pcert_length,
+                                         gnutls_privkey_t  pkey)
 {
   if (pcert)
     {
diff --git a/tls/gnutls/gtlscertificate-gnutls.h b/tls/gnutls/gtlscertificate-gnutls.h
index 2d33180..c74584b 100644
--- a/tls/gnutls/gtlscertificate-gnutls.h
+++ b/tls/gnutls/gtlscertificate-gnutls.h
@@ -46,13 +46,13 @@ const gnutls_x509_crt_t      g_tls_certificate_gnutls_get_cert        (GTlsCerti
 gboolean                     g_tls_certificate_gnutls_has_key         (GTlsCertificateGnutls *gnutls);
 gboolean                     g_tls_certificate_gnutls_is_pkcs11_backed (GTlsCertificateGnutls *gnutls);
 
-void                         g_tls_certificate_gnutls_copy            (GTlsCertificateGnutls  *gnutls,
+void                         g_tls_certificate_gnutls_copy_internals  (GTlsCertificateGnutls  *gnutls,
                                                                        const gchar            
*interaction_id,
                                                                        gnutls_pcert_st       **pcert,
                                                                        unsigned int           *pcert_length,
                                                                        gnutls_privkey_t       *pkey);
 
-void                         g_tls_certificate_gnutls_copy_free       (gnutls_pcert_st        *pcert,
+void                         g_tls_certificate_gnutls_internals_free  (gnutls_pcert_st        *pcert,
                                                                        unsigned int            pcert_length,
                                                                        gnutls_privkey_t        pkey);
 
diff --git a/tls/gnutls/gtlsoperationsthread-gnutls.c b/tls/gnutls/gtlsoperationsthread-gnutls.c
index 4714589..d5f3749 100644
--- a/tls/gnutls/gtlsoperationsthread-gnutls.c
+++ b/tls/gnutls/gtlsoperationsthread-gnutls.c
@@ -1229,7 +1229,7 @@ pin_request_cb (void         *userdata,
 static void
 clear_own_certificate_internals (GTlsOperationsThreadGnutls *self)
 {
-  g_tls_certificate_gnutls_copy_free (self->pcert, self->pcert_length, self->pkey);
+  g_tls_certificate_gnutls_internals_free (self->pcert, self->pcert_length, self->pkey);
 
   self->pcert = NULL;
   self->pcert_length = 0;
@@ -1237,10 +1237,10 @@ clear_own_certificate_internals (GTlsOperationsThreadGnutls *self)
 }
 
 static void
-get_gnutls_certificate_internals (GTlsOperationsThreadGnutls  *self,
-                                  gnutls_pcert_st            **pcert,
-                                  unsigned int                *pcert_length,
-                                  gnutls_privkey_t            *pkey)
+get_own_certificate_internals (GTlsOperationsThreadGnutls  *self,
+                               gnutls_pcert_st            **pcert,
+                               unsigned int                *pcert_length,
+                               gnutls_privkey_t            *pkey)
 {
   clear_own_certificate_internals (self);
 
@@ -1250,9 +1250,9 @@ get_gnutls_certificate_internals (GTlsOperationsThreadGnutls  *self,
       gnutls_privkey_init (&privkey);
       gnutls_privkey_set_pin_function (privkey, pin_request_cb, self);
 
-      g_tls_certificate_gnutls_copy (G_TLS_CERTIFICATE_GNUTLS (self->own_certificate),
-                                     self->interaction_id,
-                                     pcert, pcert_length, &privkey);
+      g_tls_certificate_gnutls_copy_internals (G_TLS_CERTIFICATE_GNUTLS (self->own_certificate),
+                                               self->interaction_id,
+                                               pcert, pcert_length, &privkey);
       *pkey = privkey;
     }
   else
@@ -1299,22 +1299,22 @@ retrieve_certificate_cb (gnutls_session_t              session,
       self->accepted_cas = g_list_reverse (self->accepted_cas);
     }
 
-  clear_own_certificate_internals (self);
-  get_gnutls_certificate_internals (self, pcert, pcert_length, pkey);
+  get_own_certificate_internals (self, pcert, pcert_length, pkey);
 
   if (is_client (self))
     {
       if (*pcert_length == 0)
         {
-          g_tls_certificate_gnutls_copy_free (*pcert, *pcert_length, *pkey);
+          g_tls_certificate_gnutls_internals_free (*pcert, *pcert_length, *pkey);
 
           if (g_tls_operations_thread_base_request_certificate (G_TLS_OPERATIONS_THREAD_BASE (self),
-                                                                self->op_cancellable))
-            get_gnutls_certificate_internals (self, pcert, pcert_length, pkey);
+                                                                self->op_cancellable,
+                                                                &self->own_certificate))
+            get_own_certificate_internals (self, pcert, pcert_length, pkey);
 
           if (*pcert_length == 0)
             {
-              g_tls_certificate_gnutls_copy_free (*pcert, *pcert_length, *pkey);
+              g_tls_certificate_gnutls_internals_free (*pcert, *pcert_length, *pkey);
 
               /* If there is still no client certificate, this connection will
                * probably fail, but we must not give up yet. The certificate might
@@ -1328,7 +1328,7 @@ retrieve_certificate_cb (gnutls_session_t              session,
 
       if (!*pkey)
         {
-          g_tls_certificate_gnutls_copy_free (*pcert, *pcert_length, *pkey);
+          g_tls_certificate_gnutls_internals_free (*pcert, *pcert_length, *pkey);
 
           /* No private key. GnuTLS expects it to be non-null if pcert_length is
            * nonzero, so we have to abort now.


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