[glib-networking/mcatanzaro/tls-thread] progress
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/tls-thread] progress
- Date: Tue, 31 Dec 2019 01:21:33 +0000 (UTC)
commit 7f246bbc89a4378fa88da516442589192ed78992
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Dec 30 19:21:22 2019 -0600
progress
tls/base/gtlsconnection-base.c | 57 +++++++++---------------------
tls/base/gtlsconnection-base.h | 11 ------
tls/gnutls/gtlsbackend-gnutls.c | 2 ++
tls/gnutls/gtlsclientconnection-gnutls.c | 2 ++
tls/gnutls/gtlsconnection-gnutls.c | 47 +++---------------------
tls/gnutls/gtlsoperationsthread-gnutls.h | 3 --
tls/gnutls/gtlsserverconnection-gnutls.c | 2 ++
tls/openssl/gtlsclientconnection-openssl.c | 2 ++
tls/openssl/gtlsconnection-openssl.c | 2 ++
tls/openssl/gtlsserverconnection-openssl.c | 2 ++
10 files changed, 34 insertions(+), 96 deletions(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index 4980b13..055a019 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -4,6 +4,7 @@
*
* Copyright 2009-2011 Red Hat, Inc
* Copyright 2019 Igalia S.L.
+ * Copyright 2019 Metrological Group B.V.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -202,8 +203,8 @@ enum
PROP_NEGOTIATED_PROTOCOL,
};
-gboolean
-g_tls_connection_base_is_dtls (GTlsConnectionBase *tls)
+static gboolean
+is_dtls (GTlsConnectionBase *tls)
{
GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);
@@ -779,13 +780,13 @@ yield_op (GTlsConnectionBase *tls,
/* Checks whether the underlying base stream or GDatagramBased meets
* @condition.
*/
-gboolean
-g_tls_connection_base_base_check (GTlsConnectionBase *tls,
- GIOCondition condition)
+static gboolean
+base_check (GTlsConnectionBase *tls,
+ GIOCondition condition)
{
GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);
- if (g_tls_connection_base_is_dtls (tls))
+ if (is_dtls (tls))
return g_datagram_based_condition_check (priv->base_socket, condition);
if (condition & G_IO_IN)
@@ -822,7 +823,7 @@ g_tls_connection_base_check (GTlsConnectionBase *tls,
return FALSE;
/* Defer to the base stream or GDatagramBased. */
- return g_tls_connection_base_base_check (tls, condition);
+ return base_check (tls, condition);
}
typedef struct {
@@ -1009,7 +1010,6 @@ static GSourceFuncs dtls_source_funcs =
(GSourceDummyMarshal)g_cclosure_marshal_generic
};
-/* FIXME: all needs to be threadsafe... */
GSource *
g_tls_connection_base_create_source (GTlsConnectionBase *tls,
GIOCondition condition,
@@ -1019,7 +1019,7 @@ g_tls_connection_base_create_source (GTlsConnectionBase *tls,
GSource *source, *cancellable_source;
GTlsConnectionBaseSource *tls_source;
- if (g_tls_connection_base_is_dtls (tls))
+ if (is_dtls (tls))
{
source = g_source_new (&dtls_source_funcs,
sizeof (GTlsConnectionBaseSource));
@@ -1033,7 +1033,7 @@ g_tls_connection_base_create_source (GTlsConnectionBase *tls,
tls_source = (GTlsConnectionBaseSource *)source;
tls_source->tls = g_object_ref (tls);
tls_source->condition = condition;
- if (g_tls_connection_base_is_dtls (tls))
+ if (is_dtls (tls))
tls_source->base = G_OBJECT (tls);
else if (priv->tls_istream && condition & G_IO_IN)
tls_source->base = G_OBJECT (priv->tls_istream);
@@ -1148,7 +1148,7 @@ verify_peer_certificate (GTlsConnectionBase *tls,
if (!is_client)
peer_identity = NULL;
- else if (!g_tls_connection_base_is_dtls (tls))
+ else if (!is_dtls (tls))
peer_identity = g_tls_client_connection_get_server_identity (G_TLS_CLIENT_CONNECTION (tls));
else
peer_identity = g_dtls_client_connection_get_server_identity (G_DTLS_CLIENT_CONNECTION (tls));
@@ -1198,21 +1198,19 @@ verify_certificate_cb (GTlsOperationsThreadBase *thread,
* FIXME: eliminate handshake context.
*/
- g_set_object (&priv->peer_certificate, peer_certificate);
+ g_assert (G_IS_TLS_CERTIFICATE (peer_certificate));
- if (peer_certificate)
- priv->peer_certificate_errors = verify_peer_certificate (tls, peer_certificate);
- else
- priv->peer_certificate_errors = 0;
+ g_set_object (&priv->peer_certificate, peer_certificate);
+ priv->peer_certificate_errors = verify_peer_certificate (tls, peer_certificate);
g_object_notify (G_OBJECT (tls), "peer-certificate");
g_object_notify (G_OBJECT (tls), "peer-certificate-errors");
- if (G_IS_TLS_CLIENT_CONNECTION (tls) && priv->peer_certificate)
+ if (G_IS_TLS_CLIENT_CONNECTION (tls))
{
GTlsCertificateFlags validation_flags;
- if (!g_tls_connection_base_is_dtls (tls))
+ if (!is_dtls (tls))
validation_flags =
g_tls_client_connection_get_validation_flags (G_TLS_CLIENT_CONNECTION (tls));
else
@@ -1450,7 +1448,6 @@ async_handshake_thread_completed (GObject *object,
need_finish_handshake = FALSE;
g_mutex_unlock (&priv->op_mutex);
- /* FIXME: this looks weird, why do we ignore the result of the GTask in the !need_finish_handshake case? */
if (need_finish_handshake)
{
success = g_task_propagate_boolean (G_TASK (result), &error);
@@ -1981,7 +1978,7 @@ g_tls_connection_base_close_internal (GIOStream *stream,
success = g_output_stream_close (g_io_stream_get_output_stream (priv->base_io_stream),
cancellable, &stream_error);
}
- else if (g_tls_connection_base_is_dtls (tls))
+ else if (is_dtls (tls))
{
/* We do not close underlying #GDatagramBaseds. There is no
* g_datagram_based_close() method since different datagram-based
@@ -2161,26 +2158,6 @@ g_tls_connection_base_dtls_get_negotiated_protocol (GDtlsConnection *conn)
return priv->negotiated_protocol;
}
-GDatagramBased *
-g_tls_connection_base_get_base_socket (GTlsConnectionBase *tls)
-{
- GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);
-
- g_assert (g_tls_connection_base_is_dtls (tls));
-
- return priv->base_socket;
-}
-
-GIOStream *
-g_tls_connection_base_get_base_iostream (GTlsConnectionBase *tls)
-{
- GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);
-
- g_assert (!g_tls_connection_base_is_dtls (tls));
-
- return priv->base_io_stream;
-}
-
GTlsOperationsThreadBase *
g_tls_connection_base_get_op_thread (GTlsConnectionBase *tls)
{
diff --git a/tls/base/gtlsconnection-base.h b/tls/base/gtlsconnection-base.h
index 2db056f..14845b9 100644
--- a/tls/base/gtlsconnection-base.h
+++ b/tls/base/gtlsconnection-base.h
@@ -68,8 +68,6 @@ gssize g_tls_connection_base_write (GTlsCon
gboolean g_tls_connection_base_check (GTlsConnectionBase *tls,
GIOCondition condition);
-gboolean g_tls_connection_base_base_check (GTlsConnectionBase *tls,
- GIOCondition condition);
GSource *g_tls_connection_base_create_source (GTlsConnectionBase *tls,
GIOCondition condition,
GCancellable *cancellable);
@@ -79,15 +77,6 @@ gboolean g_tls_connection_base_close_internal (GIOStre
GCancellable *cancellable,
GError **error);
-/* FIXME: audit, which are still needed? in public header? */
-
-gboolean g_tls_connection_base_is_dtls (GTlsConnectionBase *tls);
-
-GDatagramBased *g_tls_connection_base_get_base_socket (GTlsConnectionBase *tls);
-
-GIOStream *g_tls_connection_base_get_base_iostream (GTlsConnectionBase *tls);
-
-/* FIXME: needed? */
GTlsOperationsThreadBase *g_tls_connection_base_get_op_thread (GTlsConnectionBase *tls);
G_END_DECLS
diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c
index bcc7f92..4949e0c 100644
--- a/tls/gnutls/gtlsbackend-gnutls.c
+++ b/tls/gnutls/gtlsbackend-gnutls.c
@@ -3,6 +3,8 @@
* GIO - GLib Input, Output and Streaming Library
*
* Copyright 2010 Red Hat, Inc
+ * Copyright 2019 Igalia S.L.
+ * Copyright 2019 Metrological Group B.V.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/tls/gnutls/gtlsclientconnection-gnutls.c b/tls/gnutls/gtlsclientconnection-gnutls.c
index a30f169..373f8cb 100644
--- a/tls/gnutls/gtlsclientconnection-gnutls.c
+++ b/tls/gnutls/gtlsclientconnection-gnutls.c
@@ -3,6 +3,8 @@
* GIO - GLib Input, Output and Streaming Library
*
* Copyright 2010 Red Hat, Inc
+ * Copyright 2019 Igalia S.L.
+ * Copyright 2019 Metrological Group B.V.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index f7aa928..e5d0f12 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -5,6 +5,7 @@
* Copyright 2009 Red Hat, Inc
* Copyright 2015, 2016 Collabora, Ltd.
* Copyright 2019 Igalia S.L.
+ * Copyright 2019 Metrological Group B.V.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -25,47 +26,18 @@
*/
#include "config.h"
-#include "glib.h"
-
-/* FIXME: audit includes to remove */
-
-#include <errno.h>
-#include <stdarg.h>
-#include <gnutls/dtls.h>
-#include <gnutls/gnutls.h>
-#include <gnutls/x509.h>
-
#include "gtlsconnection-gnutls.h"
-#include "gtlsbackend-gnutls.h"
-#include "gtlscertificate-gnutls.h"
-#include "gtlsclientconnection-gnutls.h"
-#include "gtlsoperationsthread-gnutls.h"
-
-#ifdef G_OS_WIN32
-#include <winsock2.h>
-#include <winerror.h>
-/* It isn’t clear whether MinGW always defines EMSGSIZE. */
-#ifndef EMSGSIZE
-#define EMSGSIZE WSAEMSGSIZE
-#endif
-#endif
+#include "gtlsoperationsthread-gnutls.h"
-#include <glib/gi18n-lib.h>
-#include <glib/gprintf.h>
+#include <glib.h>
+#include <gnutls/gnutls.h>
static GInitableIface *g_tls_connection_gnutls_parent_initable_iface;
static void g_tls_connection_gnutls_initable_iface_init (GInitableIface *iface);
-typedef struct
-{
- gnutls_session_t session; /* FIXME: should be used only by GTlsOperationsThreadGnutls */
-
-} GTlsConnectionGnutlsPrivate;
-
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GTlsConnectionGnutls, g_tls_connection_gnutls, G_TYPE_TLS_CONNECTION_BASE,
- G_ADD_PRIVATE (GTlsConnectionGnutls);
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
g_tls_connection_gnutls_initable_iface_init);
);
@@ -80,16 +52,7 @@ g_tls_connection_gnutls_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
{
- GTlsConnectionGnutls *gnutls = G_TLS_CONNECTION_GNUTLS (initable);
- GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
-
- if (!g_tls_connection_gnutls_parent_initable_iface->init (initable, cancellable, error))
- return FALSE;
-
- /* FIXME bad */
- priv->session = g_tls_operations_thread_gnutls_get_session (G_TLS_OPERATIONS_THREAD_GNUTLS
(g_tls_connection_base_get_op_thread (G_TLS_CONNECTION_BASE (gnutls))));
-
- return TRUE;
+ return g_tls_connection_gnutls_parent_initable_iface->init (initable, cancellable, error);
}
static GTlsOperationsThreadBase *
diff --git a/tls/gnutls/gtlsoperationsthread-gnutls.h b/tls/gnutls/gtlsoperationsthread-gnutls.h
index 7637a42..d293de0 100644
--- a/tls/gnutls/gtlsoperationsthread-gnutls.h
+++ b/tls/gnutls/gtlsoperationsthread-gnutls.h
@@ -40,7 +40,4 @@ GTlsOperationsThreadBase *g_tls_operations_thread_gnutls_new (GTlsConnectionGnut
GDatagramBased *base_socket,
guint flags);
-/* FIXME: must remove this!!! */
-gnutls_session_t g_tls_operations_thread_gnutls_get_session (GTlsOperationsThreadGnutls *self);
-
G_END_DECLS
diff --git a/tls/gnutls/gtlsserverconnection-gnutls.c b/tls/gnutls/gtlsserverconnection-gnutls.c
index 1d834ca..13f3f92 100644
--- a/tls/gnutls/gtlsserverconnection-gnutls.c
+++ b/tls/gnutls/gtlsserverconnection-gnutls.c
@@ -3,6 +3,8 @@
* GIO - GLib Input, Output and Streaming Library
*
* Copyright 2010 Red Hat, Inc
+ * Copyright 2019 Igalia S.L.
+ * Copyright 2019 Metrological Group B.V.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/tls/openssl/gtlsclientconnection-openssl.c b/tls/openssl/gtlsclientconnection-openssl.c
index 94feb62..420f70c 100644
--- a/tls/openssl/gtlsclientconnection-openssl.c
+++ b/tls/openssl/gtlsclientconnection-openssl.c
@@ -3,6 +3,8 @@
* gtlsclientconnection-openssl.c
*
* Copyright (C) 2015 NICE s.r.l.
+ * Copyright 2019 Igalia S.L.
+ * Copyright 2019 Metrological Group B.V.
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/tls/openssl/gtlsconnection-openssl.c b/tls/openssl/gtlsconnection-openssl.c
index 43c6f16..9833612 100644
--- a/tls/openssl/gtlsconnection-openssl.c
+++ b/tls/openssl/gtlsconnection-openssl.c
@@ -3,6 +3,8 @@
* gtlsconnection-openssl.c
*
* Copyright (C) 2015 NICE s.r.l.
+ * Copyright 2019 Igalia S.L.
+ * Copyright 2019 Metrological Group B.V.
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/tls/openssl/gtlsserverconnection-openssl.c b/tls/openssl/gtlsserverconnection-openssl.c
index df451d4..2165ccb 100644
--- a/tls/openssl/gtlsserverconnection-openssl.c
+++ b/tls/openssl/gtlsserverconnection-openssl.c
@@ -3,6 +3,8 @@
* gtlsserverconnection-openssl.c
*
* Copyright (C) 2015 NICE s.r.l.
+ * Copyright 2019 Igalia S.L.
+ * Copyright 2019 Metrological Group B.V.
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]