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
46/**
47 * GTlsConnectionClass:
48 * @parent_class: The parent class.
49 * @accept_certificate: Check whether to accept a certificate.
50 * @handshake: Perform a handshake operation.
51 * @handshake_async: Start an asynchronous handshake operation.
52 * @handshake_finish: Finish an asynchronous handshake operation.
53 * @get_binding_data: Retrieve TLS channel binding data (Since: 2.66)
54 * @get_negotiated_protocol: Get ALPN-negotiated protocol (Since: 2.70)
55 *
56 * The class structure for the #GTlsConnection type.
57 *
58 * Since: 2.28
59 */
60struct _GTlsConnectionClass
61{
62 GIOStreamClass parent_class;
63
64 /* signals */
65 gboolean ( *accept_certificate) (GTlsConnection *connection,
66 GTlsCertificate *peer_cert,
67 GTlsCertificateFlags errors);
68
69 /* methods */
70 gboolean ( *handshake ) (GTlsConnection *conn,
71 GCancellable *cancellable,
72 GError **error);
73
74 void ( *handshake_async ) (GTlsConnection *conn,
75 int io_priority,
76 GCancellable *cancellable,
77 GAsyncReadyCallback callback,
78 gpointer user_data);
79 gboolean ( *handshake_finish ) (GTlsConnection *conn,
80 GAsyncResult *result,
81 GError **error);
82
83G_GNUC_BEGIN_IGNORE_DEPRECATIONS
84 gboolean ( *get_binding_data) (GTlsConnection *conn,
85 GTlsChannelBindingType type,
86 GByteArray *data,
87 GError **error);
88G_GNUC_END_IGNORE_DEPRECATIONS
89
90 const gchar *(*get_negotiated_protocol) (GTlsConnection *conn);
91
92 /*< private >*/
93 /* Padding for future expansion */
94 gpointer padding[6];
95};
96
97GLIB_AVAILABLE_IN_ALL
98GType g_tls_connection_get_type (void) G_GNUC_CONST;
99
100GLIB_DEPRECATED
101void g_tls_connection_set_use_system_certdb (GTlsConnection *conn,
102 gboolean use_system_certdb);
103GLIB_DEPRECATED
104gboolean g_tls_connection_get_use_system_certdb (GTlsConnection *conn);
105
106GLIB_AVAILABLE_IN_ALL
107void g_tls_connection_set_database (GTlsConnection *conn,
108 GTlsDatabase *database);
109GLIB_AVAILABLE_IN_ALL
110GTlsDatabase * g_tls_connection_get_database (GTlsConnection *conn);
111
112GLIB_AVAILABLE_IN_ALL
113void g_tls_connection_set_certificate (GTlsConnection *conn,
114 GTlsCertificate *certificate);
115GLIB_AVAILABLE_IN_ALL
116GTlsCertificate *g_tls_connection_get_certificate (GTlsConnection *conn);
117
118GLIB_AVAILABLE_IN_ALL
119void g_tls_connection_set_interaction (GTlsConnection *conn,
120 GTlsInteraction *interaction);
121GLIB_AVAILABLE_IN_ALL
122GTlsInteraction * g_tls_connection_get_interaction (GTlsConnection *conn);
123
124GLIB_AVAILABLE_IN_ALL
125GTlsCertificate *g_tls_connection_get_peer_certificate (GTlsConnection *conn);
126GLIB_AVAILABLE_IN_ALL
127GTlsCertificateFlags g_tls_connection_get_peer_certificate_errors (GTlsConnection *conn);
128
129GLIB_AVAILABLE_IN_ALL
130void g_tls_connection_set_require_close_notify (GTlsConnection *conn,
131 gboolean require_close_notify);
132GLIB_AVAILABLE_IN_ALL
133gboolean g_tls_connection_get_require_close_notify (GTlsConnection *conn);
134
135G_GNUC_BEGIN_IGNORE_DEPRECATIONS
136GLIB_DEPRECATED_IN_2_60
137void g_tls_connection_set_rehandshake_mode (GTlsConnection *conn,
138 GTlsRehandshakeMode mode);
139GLIB_DEPRECATED_IN_2_60
140GTlsRehandshakeMode g_tls_connection_get_rehandshake_mode (GTlsConnection *conn);
141G_GNUC_END_IGNORE_DEPRECATIONS
142
143GLIB_AVAILABLE_IN_2_60
144void g_tls_connection_set_advertised_protocols (GTlsConnection *conn,
145 const gchar * const *protocols);
146
147GLIB_AVAILABLE_IN_2_60
148const gchar * g_tls_connection_get_negotiated_protocol (GTlsConnection *conn);
149
150G_GNUC_BEGIN_IGNORE_DEPRECATIONS
151GLIB_AVAILABLE_IN_2_66
152gboolean g_tls_connection_get_channel_binding_data (GTlsConnection *conn,
153 GTlsChannelBindingType type,
154 GByteArray *data,
155 GError **error);
156G_GNUC_END_IGNORE_DEPRECATIONS
157
158GLIB_AVAILABLE_IN_ALL
159gboolean g_tls_connection_handshake (GTlsConnection *conn,
160 GCancellable *cancellable,
161 GError **error);
162
163GLIB_AVAILABLE_IN_ALL
164void g_tls_connection_handshake_async (GTlsConnection *conn,
165 int io_priority,
166 GCancellable *cancellable,
167 GAsyncReadyCallback callback,
168 gpointer user_data);
169GLIB_AVAILABLE_IN_ALL
170gboolean g_tls_connection_handshake_finish (GTlsConnection *conn,
171 GAsyncResult *result,
172 GError **error);
173
174GLIB_AVAILABLE_IN_2_70
175GTlsProtocolVersion g_tls_connection_get_protocol_version (GTlsConnection *conn);
176
177GLIB_AVAILABLE_IN_2_70
178gchar * g_tls_connection_get_ciphersuite_name (GTlsConnection *conn);
179
180/**
181 * G_TLS_ERROR:
182 *
183 * Error domain for TLS. Errors in this domain will be from the
184 * #GTlsError enumeration. See #GError for more information on error
185 * domains.
186 */
187#define G_TLS_ERROR (g_tls_error_quark ())
188GLIB_AVAILABLE_IN_ALL
189GQuark g_tls_error_quark (void);
190
191/**
192 * G_TLS_CHANNEL_BINDING_ERROR:
193 *
194 * Error domain for TLS channel binding. Errors in this domain will be from the
195 * #GTlsChannelBindingError enumeration. See #GError for more information on error
196 * domains.
197 *
198 * Since: 2.66
199 */
200#define G_TLS_CHANNEL_BINDING_ERROR (g_tls_channel_binding_error_quark ())
201GLIB_AVAILABLE_IN_2_66
202GQuark g_tls_channel_binding_error_quark (void);
203
204/*< protected >*/
205GLIB_AVAILABLE_IN_ALL
206gboolean g_tls_connection_emit_accept_certificate (GTlsConnection *conn,
207 GTlsCertificate *peer_cert,
208 GTlsCertificateFlags errors);
209
210G_END_DECLS
211
212#endif /* __G_TLS_CONNECTION_H__ */
213

source code of include/glib-2.0/gio/gtlsconnection.h