1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright (C) 2010 Red Hat, Inc.
4 *
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.
9 *
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.
14 *
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/>.
17 */
18
19#ifndef __G_TLS_CONNECTION_H__
20#define __G_TLS_CONNECTION_H__
21
22#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
23#error "Only <gio/gio.h> can be included directly."
24#endif
25
26#include <gio/giostream.h>
27
28G_BEGIN_DECLS
29
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))
36
37typedef struct _GTlsConnectionClass GTlsConnectionClass;
38typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate;
39
40struct _GTlsConnection {
41 GIOStream parent_instance;
42
43 GTlsConnectionPrivate *priv;
44};
45
46struct _GTlsConnectionClass
47{
48 GIOStreamClass parent_class;
49
50 /* signals */
51 gboolean ( *accept_certificate) (GTlsConnection *connection,
52 GTlsCertificate *peer_cert,
53 GTlsCertificateFlags errors);
54
55 /* methods */
56 gboolean ( *handshake ) (GTlsConnection *conn,
57 GCancellable *cancellable,
58 GError **error);
59
60 void ( *handshake_async ) (GTlsConnection *conn,
61 int io_priority,
62 GCancellable *cancellable,
63 GAsyncReadyCallback callback,
64 gpointer user_data);
65 gboolean ( *handshake_finish ) (GTlsConnection *conn,
66 GAsyncResult *result,
67 GError **error);
68
69G_GNUC_BEGIN_IGNORE_DEPRECATIONS
70 gboolean ( *get_binding_data) (GTlsConnection *conn,
71 GTlsChannelBindingType type,
72 GByteArray *data,
73 GError **error);
74G_GNUC_END_IGNORE_DEPRECATIONS
75
76 /*< private >*/
77 /* Padding for future expansion */
78 gpointer padding[7];
79};
80
81GLIB_AVAILABLE_IN_ALL
82GType g_tls_connection_get_type (void) G_GNUC_CONST;
83
84GLIB_DEPRECATED
85void g_tls_connection_set_use_system_certdb (GTlsConnection *conn,
86 gboolean use_system_certdb);
87GLIB_DEPRECATED
88gboolean g_tls_connection_get_use_system_certdb (GTlsConnection *conn);
89
90GLIB_AVAILABLE_IN_ALL
91void g_tls_connection_set_database (GTlsConnection *conn,
92 GTlsDatabase *database);
93GLIB_AVAILABLE_IN_ALL
94GTlsDatabase * g_tls_connection_get_database (GTlsConnection *conn);
95
96GLIB_AVAILABLE_IN_ALL
97void g_tls_connection_set_certificate (GTlsConnection *conn,
98 GTlsCertificate *certificate);
99GLIB_AVAILABLE_IN_ALL
100GTlsCertificate *g_tls_connection_get_certificate (GTlsConnection *conn);
101
102GLIB_AVAILABLE_IN_ALL
103void g_tls_connection_set_interaction (GTlsConnection *conn,
104 GTlsInteraction *interaction);
105GLIB_AVAILABLE_IN_ALL
106GTlsInteraction * g_tls_connection_get_interaction (GTlsConnection *conn);
107
108GLIB_AVAILABLE_IN_ALL
109GTlsCertificate *g_tls_connection_get_peer_certificate (GTlsConnection *conn);
110GLIB_AVAILABLE_IN_ALL
111GTlsCertificateFlags g_tls_connection_get_peer_certificate_errors (GTlsConnection *conn);
112
113GLIB_AVAILABLE_IN_ALL
114void g_tls_connection_set_require_close_notify (GTlsConnection *conn,
115 gboolean require_close_notify);
116GLIB_AVAILABLE_IN_ALL
117gboolean g_tls_connection_get_require_close_notify (GTlsConnection *conn);
118
119G_GNUC_BEGIN_IGNORE_DEPRECATIONS
120GLIB_DEPRECATED_IN_2_60
121void g_tls_connection_set_rehandshake_mode (GTlsConnection *conn,
122 GTlsRehandshakeMode mode);
123GLIB_DEPRECATED_IN_2_60
124GTlsRehandshakeMode g_tls_connection_get_rehandshake_mode (GTlsConnection *conn);
125G_GNUC_END_IGNORE_DEPRECATIONS
126
127GLIB_AVAILABLE_IN_2_60
128void g_tls_connection_set_advertised_protocols (GTlsConnection *conn,
129 const gchar * const *protocols);
130
131GLIB_AVAILABLE_IN_2_60
132const gchar * g_tls_connection_get_negotiated_protocol (GTlsConnection *conn);
133
134G_GNUC_BEGIN_IGNORE_DEPRECATIONS
135GLIB_AVAILABLE_IN_2_66
136gboolean g_tls_connection_get_channel_binding_data (GTlsConnection *conn,
137 GTlsChannelBindingType type,
138 GByteArray *data,
139 GError **error);
140G_GNUC_END_IGNORE_DEPRECATIONS
141
142GLIB_AVAILABLE_IN_ALL
143gboolean g_tls_connection_handshake (GTlsConnection *conn,
144 GCancellable *cancellable,
145 GError **error);
146
147GLIB_AVAILABLE_IN_ALL
148void g_tls_connection_handshake_async (GTlsConnection *conn,
149 int io_priority,
150 GCancellable *cancellable,
151 GAsyncReadyCallback callback,
152 gpointer user_data);
153GLIB_AVAILABLE_IN_ALL
154gboolean g_tls_connection_handshake_finish (GTlsConnection *conn,
155 GAsyncResult *result,
156 GError **error);
157
158/**
159 * G_TLS_ERROR:
160 *
161 * Error domain for TLS. Errors in this domain will be from the
162 * #GTlsError enumeration. See #GError for more information on error
163 * domains.
164 */
165#define G_TLS_ERROR (g_tls_error_quark ())
166GLIB_AVAILABLE_IN_ALL
167GQuark g_tls_error_quark (void);
168
169/**
170 * G_TLS_CHANNEL_BINDING_ERROR:
171 *
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
174 * domains.
175 *
176 * Since: 2.66
177 */
178#define G_TLS_CHANNEL_BINDING_ERROR (g_tls_channel_binding_error_quark ())
179GLIB_AVAILABLE_IN_2_66
180GQuark g_tls_channel_binding_error_quark (void);
181
182/*< protected >*/
183GLIB_AVAILABLE_IN_ALL
184gboolean g_tls_connection_emit_accept_certificate (GTlsConnection *conn,
185 GTlsCertificate *peer_cert,
186 GTlsCertificateFlags errors);
187
188G_END_DECLS
189
190#endif /* __G_TLS_CONNECTION_H__ */
191

source code of gtk/subprojects/glib/gio/gtlsconnection.h