1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2010 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 #ifndef __G_TLS_CONNECTION_H__
20 #define __G_TLS_CONNECTION_H__
22 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
23 #error "Only <gio/gio.h> can be included directly."
26 #include <gio/giostream.h>
30 #define G_TYPE_TLS_CONNECTION (g_tls_connection_get_type ())
31 #define G_TLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CONNECTION, GTlsConnection))
32 #define G_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
33 #define G_IS_TLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CONNECTION))
34 #define G_IS_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CONNECTION))
35 #define G_TLS_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
37 typedef struct _GTlsConnectionClass GTlsConnectionClass;
38 typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate;
40 struct _GTlsConnection {
41 GIOStream parent_instance;
43 GTlsConnectionPrivate *priv;
46 struct _GTlsConnectionClass
48 GIOStreamClass parent_class;
51 gboolean ( *accept_certificate) (GTlsConnection *connection,
52 GTlsCertificate *peer_cert,
53 GTlsCertificateFlags errors);
56 gboolean ( *handshake ) (GTlsConnection *conn,
57 GCancellable *cancellable,
60 void ( *handshake_async ) (GTlsConnection *conn,
62 GCancellable *cancellable,
63 GAsyncReadyCallback callback,
65 gboolean ( *handshake_finish ) (GTlsConnection *conn,
69 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
70 gboolean ( *get_binding_data) (GTlsConnection *conn,
71 GTlsChannelBindingType type,
74 G_GNUC_END_IGNORE_DEPRECATIONS
77 /* Padding for future expansion */
82 GType g_tls_connection_get_type (void) G_GNUC_CONST;
85 void g_tls_connection_set_use_system_certdb (GTlsConnection *conn,
86 gboolean use_system_certdb);
88 gboolean g_tls_connection_get_use_system_certdb (GTlsConnection *conn);
91 void g_tls_connection_set_database (GTlsConnection *conn,
92 GTlsDatabase *database);
94 GTlsDatabase * g_tls_connection_get_database (GTlsConnection *conn);
97 void g_tls_connection_set_certificate (GTlsConnection *conn,
98 GTlsCertificate *certificate);
100 GTlsCertificate *g_tls_connection_get_certificate (GTlsConnection *conn);
102 GLIB_AVAILABLE_IN_ALL
103 void g_tls_connection_set_interaction (GTlsConnection *conn,
104 GTlsInteraction *interaction);
105 GLIB_AVAILABLE_IN_ALL
106 GTlsInteraction * g_tls_connection_get_interaction (GTlsConnection *conn);
108 GLIB_AVAILABLE_IN_ALL
109 GTlsCertificate *g_tls_connection_get_peer_certificate (GTlsConnection *conn);
110 GLIB_AVAILABLE_IN_ALL
111 GTlsCertificateFlags g_tls_connection_get_peer_certificate_errors (GTlsConnection *conn);
113 GLIB_AVAILABLE_IN_ALL
114 void g_tls_connection_set_require_close_notify (GTlsConnection *conn,
115 gboolean require_close_notify);
116 GLIB_AVAILABLE_IN_ALL
117 gboolean g_tls_connection_get_require_close_notify (GTlsConnection *conn);
119 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
120 GLIB_DEPRECATED_IN_2_60
121 void g_tls_connection_set_rehandshake_mode (GTlsConnection *conn,
122 GTlsRehandshakeMode mode);
123 GLIB_DEPRECATED_IN_2_60
124 GTlsRehandshakeMode g_tls_connection_get_rehandshake_mode (GTlsConnection *conn);
125 G_GNUC_END_IGNORE_DEPRECATIONS
127 GLIB_AVAILABLE_IN_2_60
128 void g_tls_connection_set_advertised_protocols (GTlsConnection *conn,
129 const gchar * const *protocols);
131 GLIB_AVAILABLE_IN_2_60
132 const gchar * g_tls_connection_get_negotiated_protocol (GTlsConnection *conn);
134 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
135 GLIB_AVAILABLE_IN_2_66
136 gboolean g_tls_connection_get_channel_binding_data (GTlsConnection *conn,
137 GTlsChannelBindingType type,
140 G_GNUC_END_IGNORE_DEPRECATIONS
142 GLIB_AVAILABLE_IN_ALL
143 gboolean g_tls_connection_handshake (GTlsConnection *conn,
144 GCancellable *cancellable,
147 GLIB_AVAILABLE_IN_ALL
148 void g_tls_connection_handshake_async (GTlsConnection *conn,
150 GCancellable *cancellable,
151 GAsyncReadyCallback callback,
153 GLIB_AVAILABLE_IN_ALL
154 gboolean g_tls_connection_handshake_finish (GTlsConnection *conn,
155 GAsyncResult *result,
161 * Error domain for TLS. Errors in this domain will be from the
162 * #GTlsError enumeration. See #GError for more information on error
165 #define G_TLS_ERROR (g_tls_error_quark ())
166 GLIB_AVAILABLE_IN_ALL
167 GQuark g_tls_error_quark (void);
170 * G_TLS_CHANNEL_BINDING_ERROR:
172 * Error domain for TLS channel binding. Errors in this domain will be from the
173 * #GTlsChannelBindingError enumeration. See #GError for more information on error
178 #define G_TLS_CHANNEL_BINDING_ERROR (g_tls_channel_binding_error_quark ())
179 GLIB_AVAILABLE_IN_2_66
180 GQuark g_tls_channel_binding_error_quark (void);
183 GLIB_AVAILABLE_IN_ALL
184 gboolean g_tls_connection_emit_accept_certificate (GTlsConnection *conn,
185 GTlsCertificate *peer_cert,
186 GTlsCertificateFlags errors);
190 #endif /* __G_TLS_CONNECTION_H__ */