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 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, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
22 #error "Only <gio/gio.h> can be included directly."
25 #ifndef __G_TLS_CONNECTION_H__
26 #define __G_TLS_CONNECTION_H__
28 #include <gio/giostream.h>
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))
39 typedef struct _GTlsConnectionClass GTlsConnectionClass
;
40 typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate
;
42 struct _GTlsConnection
{
43 GIOStream parent_instance
;
45 GTlsConnectionPrivate
*priv
;
48 struct _GTlsConnectionClass
50 GIOStreamClass parent_class
;
53 gboolean ( *accept_certificate
) (GTlsConnection
*connection
,
54 GTlsCertificate
*peer_cert
,
55 GTlsCertificateFlags errors
);
58 gboolean ( *handshake
) (GTlsConnection
*conn
,
59 GCancellable
*cancellable
,
62 void ( *handshake_async
) (GTlsConnection
*conn
,
64 GCancellable
*cancellable
,
65 GAsyncReadyCallback callback
,
67 gboolean ( *handshake_finish
) (GTlsConnection
*conn
,
72 /* Padding for future expansion */
76 GType
g_tls_connection_get_type (void) G_GNUC_CONST
;
79 void g_tls_connection_set_use_system_certdb (GTlsConnection
*conn
,
80 gboolean use_system_certdb
);
82 gboolean
g_tls_connection_get_use_system_certdb (GTlsConnection
*conn
);
84 void g_tls_connection_set_database (GTlsConnection
*conn
,
85 GTlsDatabase
*database
);
86 GTlsDatabase
* g_tls_connection_get_database (GTlsConnection
*conn
);
88 void g_tls_connection_set_certificate (GTlsConnection
*conn
,
89 GTlsCertificate
*certificate
);
90 GTlsCertificate
*g_tls_connection_get_certificate (GTlsConnection
*conn
);
92 void g_tls_connection_set_interaction (GTlsConnection
*conn
,
93 GTlsInteraction
*interaction
);
94 GTlsInteraction
* g_tls_connection_get_interaction (GTlsConnection
*conn
);
96 GTlsCertificate
*g_tls_connection_get_peer_certificate (GTlsConnection
*conn
);
97 GTlsCertificateFlags
g_tls_connection_get_peer_certificate_errors (GTlsConnection
*conn
);
99 void g_tls_connection_set_require_close_notify (GTlsConnection
*conn
,
100 gboolean require_close_notify
);
101 gboolean
g_tls_connection_get_require_close_notify (GTlsConnection
*conn
);
103 void g_tls_connection_set_rehandshake_mode (GTlsConnection
*conn
,
104 GTlsRehandshakeMode mode
);
105 GTlsRehandshakeMode
g_tls_connection_get_rehandshake_mode (GTlsConnection
*conn
);
107 gboolean
g_tls_connection_handshake (GTlsConnection
*conn
,
108 GCancellable
*cancellable
,
111 void g_tls_connection_handshake_async (GTlsConnection
*conn
,
113 GCancellable
*cancellable
,
114 GAsyncReadyCallback callback
,
116 gboolean
g_tls_connection_handshake_finish (GTlsConnection
*conn
,
117 GAsyncResult
*result
,
123 * Error domain for TLS. Errors in this domain will be from the
124 * #GTlsError enumeration. See #GError for more information on error
127 #define G_TLS_ERROR (g_tls_error_quark ())
128 GQuark
g_tls_error_quark (void);
132 gboolean
g_tls_connection_emit_accept_certificate (GTlsConnection
*conn
,
133 GTlsCertificate
*peer_cert
,
134 GTlsCertificateFlags errors
);
138 #endif /* __G_TLS_CONNECTION_H__ */