[glib] tls: Add support for copying session data



commit 95d300eac58e6e6a7d57ce50896a7c656ebe78cf
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Thu Feb 26 22:24:36 2015 +0000

    tls: Add support for copying session data
    
    Add support for copying session data between client connections.
    This is needed for implementing FTP over SSL. Most servers use a separate
    session for each control connection and enforce sharing of each control
    connection's session between the related data connection.
    
    Copying session data between two connections is needed for two reasons:
    1) The data connection runs on a separate port and so has a different
    server_identity which means it would not normally share the session with
    the control connection using the session caching currently implemented.
    2) It is typical to have multiple control connections, each of which
    uses a different session with the same server_identity, so only one of
    these sessions gets stored in the cache. If a data connection is opened,
    (ignoring the port issue) it may try and reuse the wrong control
    connection's session, and fail.
    
    This operation is conceptually the same as OpenSSL's SSL_copy_session_id
    operation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745255

 gio/gtlsclientconnection.c |   26 ++++++++++++++++++++++++++
 gio/gtlsclientconnection.h |    6 ++++++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/gio/gtlsclientconnection.c b/gio/gtlsclientconnection.c
index 4e2aadf..397852e 100644
--- a/gio/gtlsclientconnection.c
+++ b/gio/gtlsclientconnection.c
@@ -338,3 +338,29 @@ g_tls_client_connection_get_accepted_cas (GTlsClientConnection *conn)
   g_object_get (G_OBJECT (conn), "accepted-cas", &accepted_cas, NULL);
   return accepted_cas;
 }
+
+/**
+ * g_tls_client_connection_copy_session_state:
+ * @conn: a #GTlsClientConnection
+ * @other: a #GTlsClientConnection
+ *
+ * Copies session state from one connection to another. This is
+ * not normally needed, but may be used when the same session
+ * needs to be used between different endpoints as is required
+ * by some protocols such as FTP over TLS. @source should have
+ * already completed a handshake, and @conn should not have
+ * completed a handshake.
+ *
+ * Since: 2.46
+ */
+void
+g_tls_client_connection_copy_session_state (GTlsClientConnection *conn,
+                                            GTlsClientConnection *source)
+{
+  g_return_if_fail (G_IS_TLS_CLIENT_CONNECTION (conn));
+  g_return_if_fail (G_IS_TLS_CLIENT_CONNECTION (source));
+  g_return_if_fail (G_TLS_CLIENT_CONNECTION_GET_INTERFACE (conn)->copy_session_state != NULL);
+
+  G_TLS_CLIENT_CONNECTION_GET_INTERFACE (conn)->copy_session_state (conn,
+                                                                    source);
+}
diff --git a/gio/gtlsclientconnection.h b/gio/gtlsclientconnection.h
index 23e90f5..99d1138 100644
--- a/gio/gtlsclientconnection.h
+++ b/gio/gtlsclientconnection.h
@@ -46,6 +46,8 @@ struct _GTlsClientConnectionInterface
 {
   GTypeInterface g_iface;
 
+  void     ( *copy_session_state )     (GTlsClientConnection       *conn,
+                                        GTlsClientConnection       *source);
 };
 
 GLIB_AVAILABLE_IN_ALL
@@ -74,6 +76,10 @@ void                  g_tls_client_connection_set_use_ssl3         (GTlsClientCo
 GLIB_AVAILABLE_IN_ALL
 GList *               g_tls_client_connection_get_accepted_cas     (GTlsClientConnection    *conn);
 
+GLIB_AVAILABLE_IN_2_46
+void                  g_tls_client_connection_copy_session_state   (GTlsClientConnection    *conn,
+                                                                    GTlsClientConnection    *source);
+
 G_END_DECLS
 
 #endif /* __G_TLS_CLIENT_CONNECTION_H__ */


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