Change LGPL-2.1+ to LGPL-2.1-or-later
[platform/upstream/glib.git] / gio / gtlsconnection.h
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright (C) 2010 Red Hat, Inc.
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General
18  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef __G_TLS_CONNECTION_H__
22 #define __G_TLS_CONNECTION_H__
23
24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
26 #endif
27
28 #include <gio/giostream.h>
29
30 G_BEGIN_DECLS
31
32 #define G_TYPE_TLS_CONNECTION            (g_tls_connection_get_type ())
33 #define G_TLS_CONNECTION(inst)           (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CONNECTION, GTlsConnection))
34 #define G_TLS_CONNECTION_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
35 #define G_IS_TLS_CONNECTION(inst)        (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CONNECTION))
36 #define G_IS_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CONNECTION))
37 #define G_TLS_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
38
39 typedef struct _GTlsConnectionClass   GTlsConnectionClass;
40 typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate;
41
42 struct _GTlsConnection {
43   GIOStream parent_instance;
44
45   GTlsConnectionPrivate *priv;
46 };
47
48 /**
49  * GTlsConnectionClass:
50  * @parent_class: The parent class.
51  * @accept_certificate: Check whether to accept a certificate.
52  * @handshake: Perform a handshake operation.
53  * @handshake_async: Start an asynchronous handshake operation.
54  * @handshake_finish: Finish an asynchronous handshake operation.
55  * @get_binding_data: Retrieve TLS channel binding data (Since: 2.66)
56  * @get_negotiated_protocol: Get ALPN-negotiated protocol (Since: 2.70)
57  *
58  * The class structure for the #GTlsConnection type.
59  *
60  * Since: 2.28
61  */
62 struct _GTlsConnectionClass
63 {
64   GIOStreamClass parent_class;
65
66   /* signals */
67   gboolean          ( *accept_certificate) (GTlsConnection       *connection,
68                                             GTlsCertificate      *peer_cert,
69                                             GTlsCertificateFlags  errors);
70
71   /* methods */
72   gboolean ( *handshake )        (GTlsConnection       *conn,
73                                   GCancellable         *cancellable,
74                                   GError              **error);
75
76   void     ( *handshake_async )  (GTlsConnection       *conn,
77                                   int                   io_priority,
78                                   GCancellable         *cancellable,
79                                   GAsyncReadyCallback   callback,
80                                   gpointer              user_data);
81   gboolean ( *handshake_finish ) (GTlsConnection       *conn,
82                                   GAsyncResult         *result,
83                                   GError              **error);
84
85 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
86   gboolean ( *get_binding_data)  (GTlsConnection          *conn,
87                                   GTlsChannelBindingType   type,
88                                   GByteArray              *data,
89                                   GError                 **error);
90 G_GNUC_END_IGNORE_DEPRECATIONS
91
92   const gchar *(*get_negotiated_protocol) (GTlsConnection *conn);
93
94   /*< private >*/
95   /* Padding for future expansion */
96   gpointer padding[6];
97 };
98
99 GIO_AVAILABLE_IN_ALL
100 GType                 g_tls_connection_get_type                    (void) G_GNUC_CONST;
101
102 GIO_DEPRECATED
103 void                  g_tls_connection_set_use_system_certdb       (GTlsConnection       *conn,
104                                                                     gboolean              use_system_certdb);
105 GIO_DEPRECATED
106 gboolean              g_tls_connection_get_use_system_certdb       (GTlsConnection       *conn);
107
108 GIO_AVAILABLE_IN_ALL
109 void                  g_tls_connection_set_database                (GTlsConnection       *conn,
110                                                                     GTlsDatabase         *database);
111 GIO_AVAILABLE_IN_ALL
112 GTlsDatabase *        g_tls_connection_get_database                (GTlsConnection       *conn);
113
114 GIO_AVAILABLE_IN_ALL
115 void                  g_tls_connection_set_certificate             (GTlsConnection       *conn,
116                                                                     GTlsCertificate      *certificate);
117 GIO_AVAILABLE_IN_ALL
118 GTlsCertificate      *g_tls_connection_get_certificate             (GTlsConnection       *conn);
119
120 GIO_AVAILABLE_IN_ALL
121 void                  g_tls_connection_set_interaction             (GTlsConnection       *conn,
122                                                                     GTlsInteraction      *interaction);
123 GIO_AVAILABLE_IN_ALL
124 GTlsInteraction *     g_tls_connection_get_interaction             (GTlsConnection       *conn);
125
126 GIO_AVAILABLE_IN_ALL
127 GTlsCertificate      *g_tls_connection_get_peer_certificate        (GTlsConnection       *conn);
128 GIO_AVAILABLE_IN_ALL
129 GTlsCertificateFlags  g_tls_connection_get_peer_certificate_errors (GTlsConnection       *conn);
130
131 GIO_AVAILABLE_IN_ALL
132 void                  g_tls_connection_set_require_close_notify    (GTlsConnection       *conn,
133                                                                     gboolean              require_close_notify);
134 GIO_AVAILABLE_IN_ALL
135 gboolean              g_tls_connection_get_require_close_notify    (GTlsConnection       *conn);
136
137 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
138 GIO_DEPRECATED_IN_2_60
139 void                  g_tls_connection_set_rehandshake_mode        (GTlsConnection       *conn,
140                                                                     GTlsRehandshakeMode   mode);
141 GIO_DEPRECATED_IN_2_60
142 GTlsRehandshakeMode   g_tls_connection_get_rehandshake_mode        (GTlsConnection       *conn);
143 G_GNUC_END_IGNORE_DEPRECATIONS
144
145 GIO_AVAILABLE_IN_2_60
146 void                  g_tls_connection_set_advertised_protocols    (GTlsConnection       *conn,
147                                                                     const gchar * const  *protocols);
148
149 GIO_AVAILABLE_IN_2_60
150 const gchar *         g_tls_connection_get_negotiated_protocol     (GTlsConnection       *conn);
151
152 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
153 GIO_AVAILABLE_IN_2_66
154 gboolean              g_tls_connection_get_channel_binding_data    (GTlsConnection          *conn,
155                                                                     GTlsChannelBindingType   type,
156                                                                     GByteArray              *data,
157                                                                     GError                 **error);
158 G_GNUC_END_IGNORE_DEPRECATIONS
159
160 GIO_AVAILABLE_IN_ALL
161 gboolean              g_tls_connection_handshake                   (GTlsConnection       *conn,
162                                                                     GCancellable         *cancellable,
163                                                                     GError              **error);
164
165 GIO_AVAILABLE_IN_ALL
166 void                  g_tls_connection_handshake_async             (GTlsConnection       *conn,
167                                                                     int                   io_priority,
168                                                                     GCancellable         *cancellable,
169                                                                     GAsyncReadyCallback   callback,
170                                                                     gpointer              user_data);
171 GIO_AVAILABLE_IN_ALL
172 gboolean              g_tls_connection_handshake_finish            (GTlsConnection       *conn,
173                                                                     GAsyncResult         *result,
174                                                                     GError              **error);
175
176 GIO_AVAILABLE_IN_2_70
177 GTlsProtocolVersion   g_tls_connection_get_protocol_version        (GTlsConnection       *conn);
178
179 GIO_AVAILABLE_IN_2_70
180 gchar *               g_tls_connection_get_ciphersuite_name        (GTlsConnection       *conn);
181
182 /**
183  * G_TLS_ERROR:
184  *
185  * Error domain for TLS. Errors in this domain will be from the
186  * #GTlsError enumeration. See #GError for more information on error
187  * domains.
188  */
189 #define G_TLS_ERROR (g_tls_error_quark ())
190 GIO_AVAILABLE_IN_ALL
191 GQuark g_tls_error_quark (void);
192
193 /**
194  * G_TLS_CHANNEL_BINDING_ERROR:
195  *
196  * Error domain for TLS channel binding. Errors in this domain will be from the
197  * #GTlsChannelBindingError enumeration. See #GError for more information on error
198  * domains.
199  *
200  * Since: 2.66
201  */
202 #define G_TLS_CHANNEL_BINDING_ERROR (g_tls_channel_binding_error_quark ())
203 GIO_AVAILABLE_IN_2_66
204 GQuark g_tls_channel_binding_error_quark (void);
205
206 /*< protected >*/
207 GIO_AVAILABLE_IN_ALL
208 gboolean              g_tls_connection_emit_accept_certificate     (GTlsConnection       *conn,
209                                                                     GTlsCertificate      *peer_cert,
210                                                                     GTlsCertificateFlags  errors);
211
212 G_END_DECLS
213
214 #endif /* __G_TLS_CONNECTION_H__ */