gtlsconnection.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. #ifndef __G_TLS_CONNECTION_H__
  21. #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."
  24. #endif
  25. #include <gio/giostream.h>
  26. G_BEGIN_DECLS
  27. #define G_TYPE_TLS_CONNECTION (g_tls_connection_get_type ())
  28. #define G_TLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CONNECTION, GTlsConnection))
  29. #define G_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
  30. #define G_IS_TLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CONNECTION))
  31. #define G_IS_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CONNECTION))
  32. #define G_TLS_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
  33. typedef struct _GTlsConnectionClass GTlsConnectionClass;
  34. typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate;
  35. struct _GTlsConnection {
  36. GIOStream parent_instance;
  37. GTlsConnectionPrivate *priv;
  38. };
  39. /**
  40. * GTlsConnectionClass:
  41. * @parent_class: The parent class.
  42. * @accept_certificate: Check whether to accept a certificate.
  43. * @handshake: Perform a handshake operation.
  44. * @handshake_async: Start an asynchronous handshake operation.
  45. * @handshake_finish: Finish an asynchronous handshake operation.
  46. * @get_binding_data: Retrieve TLS channel binding data (Since: 2.66)
  47. * @get_negotiated_protocol: Get ALPN-negotiated protocol (Since: 2.70)
  48. *
  49. * The class structure for the #GTlsConnection type.
  50. *
  51. * Since: 2.28
  52. */
  53. struct _GTlsConnectionClass
  54. {
  55. GIOStreamClass parent_class;
  56. /* signals */
  57. gboolean ( *accept_certificate) (GTlsConnection *connection,
  58. GTlsCertificate *peer_cert,
  59. GTlsCertificateFlags errors);
  60. /* methods */
  61. gboolean ( *handshake ) (GTlsConnection *conn,
  62. GCancellable *cancellable,
  63. GError **error);
  64. void ( *handshake_async ) (GTlsConnection *conn,
  65. int io_priority,
  66. GCancellable *cancellable,
  67. GAsyncReadyCallback callback,
  68. gpointer user_data);
  69. gboolean ( *handshake_finish ) (GTlsConnection *conn,
  70. GAsyncResult *result,
  71. GError **error);
  72. G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  73. gboolean ( *get_binding_data) (GTlsConnection *conn,
  74. GTlsChannelBindingType type,
  75. GByteArray *data,
  76. GError **error);
  77. G_GNUC_END_IGNORE_DEPRECATIONS
  78. const gchar *(*get_negotiated_protocol) (GTlsConnection *conn);
  79. /*< private >*/
  80. /* Padding for future expansion */
  81. gpointer padding[6];
  82. };
  83. GIO_AVAILABLE_IN_ALL
  84. GType g_tls_connection_get_type (void) G_GNUC_CONST;
  85. GIO_DEPRECATED
  86. void g_tls_connection_set_use_system_certdb (GTlsConnection *conn,
  87. gboolean use_system_certdb);
  88. GIO_DEPRECATED
  89. gboolean g_tls_connection_get_use_system_certdb (GTlsConnection *conn);
  90. GIO_AVAILABLE_IN_ALL
  91. void g_tls_connection_set_database (GTlsConnection *conn,
  92. GTlsDatabase *database);
  93. GIO_AVAILABLE_IN_ALL
  94. GTlsDatabase * g_tls_connection_get_database (GTlsConnection *conn);
  95. GIO_AVAILABLE_IN_ALL
  96. void g_tls_connection_set_certificate (GTlsConnection *conn,
  97. GTlsCertificate *certificate);
  98. GIO_AVAILABLE_IN_ALL
  99. GTlsCertificate *g_tls_connection_get_certificate (GTlsConnection *conn);
  100. GIO_AVAILABLE_IN_ALL
  101. void g_tls_connection_set_interaction (GTlsConnection *conn,
  102. GTlsInteraction *interaction);
  103. GIO_AVAILABLE_IN_ALL
  104. GTlsInteraction * g_tls_connection_get_interaction (GTlsConnection *conn);
  105. GIO_AVAILABLE_IN_ALL
  106. GTlsCertificate *g_tls_connection_get_peer_certificate (GTlsConnection *conn);
  107. GIO_AVAILABLE_IN_ALL
  108. GTlsCertificateFlags g_tls_connection_get_peer_certificate_errors (GTlsConnection *conn);
  109. GIO_AVAILABLE_IN_ALL
  110. void g_tls_connection_set_require_close_notify (GTlsConnection *conn,
  111. gboolean require_close_notify);
  112. GIO_AVAILABLE_IN_ALL
  113. gboolean g_tls_connection_get_require_close_notify (GTlsConnection *conn);
  114. G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  115. GIO_DEPRECATED_IN_2_60
  116. void g_tls_connection_set_rehandshake_mode (GTlsConnection *conn,
  117. GTlsRehandshakeMode mode);
  118. GIO_DEPRECATED_IN_2_60
  119. GTlsRehandshakeMode g_tls_connection_get_rehandshake_mode (GTlsConnection *conn);
  120. G_GNUC_END_IGNORE_DEPRECATIONS
  121. GIO_AVAILABLE_IN_2_60
  122. void g_tls_connection_set_advertised_protocols (GTlsConnection *conn,
  123. const gchar * const *protocols);
  124. GIO_AVAILABLE_IN_2_60
  125. const gchar * g_tls_connection_get_negotiated_protocol (GTlsConnection *conn);
  126. G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  127. GIO_AVAILABLE_IN_2_66
  128. gboolean g_tls_connection_get_channel_binding_data (GTlsConnection *conn,
  129. GTlsChannelBindingType type,
  130. GByteArray *data,
  131. GError **error);
  132. G_GNUC_END_IGNORE_DEPRECATIONS
  133. GIO_AVAILABLE_IN_ALL
  134. gboolean g_tls_connection_handshake (GTlsConnection *conn,
  135. GCancellable *cancellable,
  136. GError **error);
  137. GIO_AVAILABLE_IN_ALL
  138. void g_tls_connection_handshake_async (GTlsConnection *conn,
  139. int io_priority,
  140. GCancellable *cancellable,
  141. GAsyncReadyCallback callback,
  142. gpointer user_data);
  143. GIO_AVAILABLE_IN_ALL
  144. gboolean g_tls_connection_handshake_finish (GTlsConnection *conn,
  145. GAsyncResult *result,
  146. GError **error);
  147. GIO_AVAILABLE_IN_2_70
  148. GTlsProtocolVersion g_tls_connection_get_protocol_version (GTlsConnection *conn);
  149. GIO_AVAILABLE_IN_2_70
  150. gchar * g_tls_connection_get_ciphersuite_name (GTlsConnection *conn);
  151. /**
  152. * G_TLS_ERROR:
  153. *
  154. * Error domain for TLS. Errors in this domain will be from the
  155. * #GTlsError enumeration. See #GError for more information on error
  156. * domains.
  157. */
  158. #define G_TLS_ERROR (g_tls_error_quark ())
  159. GIO_AVAILABLE_IN_ALL
  160. GQuark g_tls_error_quark (void);
  161. /**
  162. * G_TLS_CHANNEL_BINDING_ERROR:
  163. *
  164. * Error domain for TLS channel binding. Errors in this domain will be from the
  165. * #GTlsChannelBindingError enumeration. See #GError for more information on error
  166. * domains.
  167. *
  168. * Since: 2.66
  169. */
  170. #define G_TLS_CHANNEL_BINDING_ERROR (g_tls_channel_binding_error_quark ())
  171. GIO_AVAILABLE_IN_2_66
  172. GQuark g_tls_channel_binding_error_quark (void);
  173. /*< protected >*/
  174. GIO_AVAILABLE_IN_ALL
  175. gboolean g_tls_connection_emit_accept_certificate (GTlsConnection *conn,
  176. GTlsCertificate *peer_cert,
  177. GTlsCertificateFlags errors);
  178. G_END_DECLS
  179. #endif /* __G_TLS_CONNECTION_H__ */