Interface

GioDtlsConnection

since: 2.48

Description [src]

interface Gio.DtlsConnection : Gio.DatagramBased

GDtlsConnection is the base DTLS connection class type, which wraps a GDatagramBased and provides DTLS encryption on top of it. Its subclasses, GDtlsClientConnection and GDtlsServerConnection, implement client-side and server-side DTLS, respectively.

For TLS support, see GTlsConnection.

As DTLS is datagram based, GDtlsConnection implements GDatagramBased, presenting a datagram-socket-like API for the encrypted connection. This operates over a base datagram connection, which is also a GDatagramBased (GDtlsConnection:base-socket).

To close a DTLS connection, use g_dtls_connection_close().

Neither GDtlsServerConnection or GDtlsClientConnection set the peer address on their base GDatagramBased if it is a GSocket — it is up to the caller to do that if they wish. If they do not, and g_socket_close() is called on the base socket, the GDtlsConnection will not raise a G_IO_ERROR_NOT_CONNECTED error on further I/O.

Available since: 2.48

Prerequisite

In order to implement DtlsConnection, your type must inherit fromGDatagramBased.

Instance methods

g_dtls_connection_close

Close the DTLS connection. This is equivalent to calling g_dtls_connection_shutdown() to shut down both sides of the connection.

since: 2.48

g_dtls_connection_close_async

Asynchronously close the DTLS connection. See g_dtls_connection_close() for more information.

since: 2.48

g_dtls_connection_close_finish

Finish an asynchronous TLS close operation. See g_dtls_connection_close() for more information.

since: 2.48

g_dtls_connection_emit_accept_certificate

Used by GDtlsConnection implementations to emit the GDtlsConnection::accept-certificate signal.

since: 2.48

g_dtls_connection_get_certificate

Gets conns certificate, as set by g_dtls_connection_set_certificate().

since: 2.48

g_dtls_connection_get_channel_binding_data

Query the TLS backend for TLS channel binding data of type for conn.

since: 2.66

g_dtls_connection_get_ciphersuite_name

Returns the name of the current DTLS ciphersuite, or NULL if the connection has not handshaked or has been closed. Beware that the TLS backend may use any of multiple different naming conventions, because OpenSSL and GnuTLS have their own ciphersuite naming conventions that are different from each other and different from the standard, IANA- registered ciphersuite names. The ciphersuite name is intended to be displayed to the user for informative purposes only, and parsing it is not recommended.

since: 2.70

g_dtls_connection_get_database

Gets the certificate database that conn uses to verify peer certificates. See g_dtls_connection_set_database().

since: 2.48

g_dtls_connection_get_interaction

Get the object that will be used to interact with the user. It will be used for things like prompting the user for passwords. If NULL is returned, then no user interaction will occur for this connection.

since: 2.48

g_dtls_connection_get_negotiated_protocol

Gets the name of the application-layer protocol negotiated during the handshake.

since: 2.60

g_dtls_connection_get_peer_certificate

Gets conns peer’s certificate after the handshake has completed or failed. (It is not set during the emission of GDtlsConnection::accept-certificate.).

since: 2.48

g_dtls_connection_get_peer_certificate_errors

Gets the errors associated with validating conns peer’s certificate, after the handshake has completed or failed. (It is not set during the emission of GDtlsConnection::accept-certificate.).

since: 2.48

g_dtls_connection_get_protocol_version

Returns the current DTLS protocol version, which may be G_TLS_PROTOCOL_VERSION_UNKNOWN if the connection has not handshaked, or has been closed, or if the TLS backend has implemented a protocol version that is not a recognized GTlsProtocolVersion.

since: 2.70

g_dtls_connection_get_rehandshake_mode

Gets conn rehandshaking mode. See g_dtls_connection_set_rehandshake_mode() for details.

deprecated: 2.64. since: 2.48

g_dtls_connection_get_require_close_notify

Tests whether or not conn expects a proper TLS close notification when the connection is closed. See g_dtls_connection_set_require_close_notify() for details.

since: 2.48

g_dtls_connection_handshake

Attempts a TLS handshake on conn.

since: 2.48

g_dtls_connection_handshake_async

Asynchronously performs a TLS handshake on conn. See g_dtls_connection_handshake() for more information.

since: 2.48

g_dtls_connection_handshake_finish

Finish an asynchronous TLS handshake operation. See g_dtls_connection_handshake() for more information.

since: 2.48

g_dtls_connection_set_advertised_protocols

Sets the list of application-layer protocols to advertise that the caller is willing to speak on this connection. The Application-Layer Protocol Negotiation (ALPN) extension will be used to negotiate a compatible protocol with the peer; use g_dtls_connection_get_negotiated_protocol() to find the negotiated protocol after the handshake. Specifying NULL for the the value of protocols will disable ALPN negotiation.

since: 2.60

g_dtls_connection_set_certificate

This sets the certificate that conn will present to its peer during the TLS handshake. For a GDtlsServerConnection, it is mandatory to set this, and that will normally be done at construct time.

since: 2.48

g_dtls_connection_set_database

Sets the certificate database that is used to verify peer certificates. This is set to the default database by default. See g_tls_backend_get_default_database(). If set to NULL, then peer certificate validation will always set the G_TLS_CERTIFICATE_UNKNOWN_CA error (meaning GDtlsConnection::accept-certificate will always be emitted on client-side connections, unless that bit is not set in GDtlsClientConnection:validation-flags).

since: 2.48

g_dtls_connection_set_interaction

Set the object that will be used to interact with the user. It will be used for things like prompting the user for passwords.

since: 2.48

g_dtls_connection_set_rehandshake_mode

Since GLib 2.64, changing the rehandshake mode is no longer supported and will have no effect. With TLS 1.3, rehandshaking has been removed from the TLS protocol, replaced by separate post-handshake authentication and rekey operations.

deprecated: 2.60. since: 2.48

g_dtls_connection_set_require_close_notify

Sets whether or not conn expects a proper TLS close notification before the connection is closed. If this is TRUE (the default), then conn will expect to receive a TLS close notification from its peer before the connection is closed, and will return a G_TLS_ERROR_EOF error if the connection is closed without proper notification (since this may indicate a network error, or man-in-the-middle attack).

since: 2.48

g_dtls_connection_shutdown

Shut down part or all of a DTLS connection.

since: 2.48

g_dtls_connection_shutdown_async

Asynchronously shut down part or all of the DTLS connection. See g_dtls_connection_shutdown() for more information.

since: 2.48

g_dtls_connection_shutdown_finish

Finish an asynchronous TLS shutdown operation. See g_dtls_connection_shutdown() for more information.

since: 2.48

Properties

Gio.DtlsConnection:advertised-protocols

The list of application-layer protocols that the connection advertises that it is willing to speak. See g_dtls_connection_set_advertised_protocols().

since: 2.60

Gio.DtlsConnection:base-socket

The GDatagramBased that the connection wraps. Note that this may be any implementation of GDatagramBased, not just a GSocket.

since: 2.48

Gio.DtlsConnection:certificate

The connection’s certificate; see g_dtls_connection_set_certificate().

since: 2.48

Gio.DtlsConnection:ciphersuite-name

The name of the DTLS ciphersuite in use. See g_dtls_connection_get_ciphersuite_name().

since: 2.70

Gio.DtlsConnection:database

The certificate database to use when verifying this TLS connection. If no certificate database is set, then the default database will be used. See g_tls_backend_get_default_database().

since: 2.48

Gio.DtlsConnection:interaction

A GTlsInteraction object to be used when the connection or certificate database need to interact with the user. This will be used to prompt the user for passwords where necessary.

since: 2.48

Gio.DtlsConnection:negotiated-protocol

The application-layer protocol negotiated during the TLS handshake. See g_dtls_connection_get_negotiated_protocol().

since: 2.60

Gio.DtlsConnection:peer-certificate

The connection’s peer’s certificate, after the TLS handshake has completed or failed. Note in particular that this is not yet set during the emission of GDtlsConnection::accept-certificate.

since: 2.48

Gio.DtlsConnection:peer-certificate-errors

The errors noticed while verifying GDtlsConnection:peer-certificate. Normally this should be 0, but it may not be if GDtlsClientConnection:validation-flags is not G_TLS_CERTIFICATE_VALIDATE_ALL, or if GDtlsConnection::accept-certificate overrode the default behavior.

since: 2.48

Gio.DtlsConnection:protocol-version

The DTLS protocol version in use. See g_dtls_connection_get_protocol_version().

since: 2.70

Gio.DtlsConnection:rehandshake-mode

The rehandshaking mode. See g_dtls_connection_set_rehandshake_mode().

deprecated: 2.60 since: 2.48

Gio.DtlsConnection:require-close-notify

Whether or not proper TLS close notification is required. See g_dtls_connection_set_require_close_notify().

since: 2.48

Signals

Gio.DtlsConnection::accept-certificate

Emitted during the TLS handshake after the peer certificate has been received. You can examine peer_certs certification path by calling g_tls_certificate_get_issuer() on it.

since: 2.48

Interface structure

struct GioDtlsConnectionInterface {
  GTypeInterface g_iface;
  gboolean (* accept_certificate) (
    GDtlsConnection* connection,
    GTlsCertificate* peer_cert,
    GTlsCertificateFlags errors
  );
  gboolean (* handshake) (
    GDtlsConnection* conn,
    GCancellable* cancellable,
    GError** error
  );
  void (* handshake_async) (
    GDtlsConnection* conn,
    int io_priority,
    GCancellable* cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data
  );
  gboolean (* handshake_finish) (
    GDtlsConnection* conn,
    GAsyncResult* result,
    GError** error
  );
  gboolean (* shutdown) (
    GDtlsConnection* conn,
    gboolean shutdown_read,
    gboolean shutdown_write,
    GCancellable* cancellable,
    GError** error
  );
  void (* shutdown_async) (
    GDtlsConnection* conn,
    gboolean shutdown_read,
    gboolean shutdown_write,
    int io_priority,
    GCancellable* cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data
  );
  gboolean (* shutdown_finish) (
    GDtlsConnection* conn,
    GAsyncResult* result,
    GError** error
  );
  void (* set_advertised_protocols) (
    GDtlsConnection* conn,
    const gchar* const* protocols
  );
  const gchar* (* get_negotiated_protocol) (
    GDtlsConnection* conn
  );
  gboolean (* get_binding_data) (
    GDtlsConnection* conn,
    GTlsChannelBindingType type,
    GByteArray* data,
    GError** error
  );
  
}

Virtual method table for a GDtlsConnection implementation.

Interface members
g_iface
GTypeInterface
 

The parent interface.

accept_certificate
gboolean (* accept_certificate) (
    GDtlsConnection* connection,
    GTlsCertificate* peer_cert,
    GTlsCertificateFlags errors
  )
 

Check whether to accept a certificate.

handshake
gboolean (* handshake) (
    GDtlsConnection* conn,
    GCancellable* cancellable,
    GError** error
  )
 

Perform a handshake operation.

handshake_async
void (* handshake_async) (
    GDtlsConnection* conn,
    int io_priority,
    GCancellable* cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data
  )
 

Start an asynchronous handshake operation.

handshake_finish
gboolean (* handshake_finish) (
    GDtlsConnection* conn,
    GAsyncResult* result,
    GError** error
  )
 

Finish an asynchronous handshake operation.

shutdown
gboolean (* shutdown) (
    GDtlsConnection* conn,
    gboolean shutdown_read,
    gboolean shutdown_write,
    GCancellable* cancellable,
    GError** error
  )
 

Shut down one or both directions of the connection.

shutdown_async
void (* shutdown_async) (
    GDtlsConnection* conn,
    gboolean shutdown_read,
    gboolean shutdown_write,
    int io_priority,
    GCancellable* cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data
  )
 

Start an asynchronous shutdown operation.

shutdown_finish
gboolean (* shutdown_finish) (
    GDtlsConnection* conn,
    GAsyncResult* result,
    GError** error
  )
 

Finish an asynchronous shutdown operation.

set_advertised_protocols
void (* set_advertised_protocols) (
    GDtlsConnection* conn,
    const gchar* const* protocols
  )
 

Set APLN protocol list (Since: 2.60).

get_negotiated_protocol
const gchar* (* get_negotiated_protocol) (
    GDtlsConnection* conn
  )
 

Get ALPN-negotiated protocol (Since: 2.60).

get_binding_data
gboolean (* get_binding_data) (
    GDtlsConnection* conn,
    GTlsChannelBindingType type,
    GByteArray* data,
    GError** error
  )
 

Retrieve TLS channel binding data (Since: 2.66).

Virtual methods

Gio.DtlsConnection.accept_certificate

Check whether to accept a certificate.

Gio.DtlsConnection.get_binding_data

Retrieve TLS channel binding data (Since: 2.66).

Gio.DtlsConnection.get_negotiated_protocol

Gets the name of the application-layer protocol negotiated during the handshake.

since: 2.60

Gio.DtlsConnection.handshake

Attempts a TLS handshake on conn.

since: 2.48

Gio.DtlsConnection.handshake_async

Asynchronously performs a TLS handshake on conn. See g_dtls_connection_handshake() for more information.

since: 2.48

Gio.DtlsConnection.handshake_finish

Finish an asynchronous TLS handshake operation. See g_dtls_connection_handshake() for more information.

since: 2.48

Gio.DtlsConnection.set_advertised_protocols

Sets the list of application-layer protocols to advertise that the caller is willing to speak on this connection. The Application-Layer Protocol Negotiation (ALPN) extension will be used to negotiate a compatible protocol with the peer; use g_dtls_connection_get_negotiated_protocol() to find the negotiated protocol after the handshake. Specifying NULL for the the value of protocols will disable ALPN negotiation.

since: 2.60

Gio.DtlsConnection.shutdown

Shut down part or all of a DTLS connection.

since: 2.48

Gio.DtlsConnection.shutdown_async

Asynchronously shut down part or all of the DTLS connection. See g_dtls_connection_shutdown() for more information.

since: 2.48

Gio.DtlsConnection.shutdown_finish

Finish an asynchronous TLS shutdown operation. See g_dtls_connection_shutdown() for more information.

since: 2.48