gio.dtls_connection

Module for [DtlsConnection] interface

Types 2

[gio.dtls_connection.DtlsConnection] is the base DTLS connection class type, which wraps a [gio.datagram_based.DatagramBased] and provides DTLS encryption on top of it. Its subclasses, [gio.dtls_client_connection.DtlsClientConnection] and [gio.dtls_server_connection.DtlsServerConnection], implement client-side and server-side DTLS, respectively.

For TLS support, see [gio.tls_connection.TlsConnection].

As DTLS is datagram based, [gio.dtls_connection.DtlsConnection] implements [gio.datagram_based.DatagramBased], presenting a datagram-socket-like API for the encrypted connection. This operates over a base datagram connection, which is also a [gio.datagram_based.DatagramBased] (property@Gio.DtlsConnection:base-socket).

To close a DTLS connection, use [gio.dtls_connection.DtlsConnection.close].

Neither [gio.dtls_server_connection.DtlsServerConnection] or [gio.dtls_client_connection.DtlsClientConnection] set the peer address on their base [gio.datagram_based.DatagramBased] if it is a [gio.socket.Socket] — it is up to the caller to do that if they wish. If they do not, and [gio.socket.Socket.close] is called on the base socket, the [gio.dtls_connection.DtlsConnection] will not raise a [gio.types.IOErrorEnum.NotConnected] error on further I/O.

Methods
gio.datagram_based.DatagramBased baseSocket() @propertyGet `baseSocket` property. Returns: The #GDatagramBased that the connection wraps. Note that this may be any implementation of #GDatagramBased, not just a #GSocket.
gio.tls_certificate.TlsCertificate certificate() @propertyGet `certificate` property. Returns: The connection's certificate; see [gio.dtls_connection.DtlsConnection.setCertificate].
void certificate(gio.tls_certificate.TlsCertificate propval) @propertySet `certificate` property. Params: propval = The connection's certificate; see [gio.dtls_connection.DtlsConnection.setCertificate].
string ciphersuiteName() @propertyGet `ciphersuiteName` property. Returns: The name of the DTLS ciphersuite in use. See [gio.dtls_connection.DtlsConnection.getCiphersuiteName].
gio.tls_database.TlsDatabase database() @propertyGet `database` property. Returns: The certificate database to use when verifying this TLS connection. If no certificate database is set, then the default database will be used. See [gio.tls_backend...
void database(gio.tls_database.TlsDatabase propval) @propertySet `database` property. Params: propval = The certificate database to use when verifying this TLS connection. If no certificate database is set, then the default database will be used. See [gio.tl...
gio.tls_interaction.TlsInteraction interaction() @propertyGet `interaction` property. Returns: 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 passwo...
void interaction(gio.tls_interaction.TlsInteraction propval) @propertySet `interaction` property. Params: propval = 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 f...
string negotiatedProtocol() @propertyGet `negotiatedProtocol` property. Returns: The application-layer protocol negotiated during the TLS handshake. See [gio.dtls_connection.DtlsConnection.getNegotiatedProtocol].
gio.tls_certificate.TlsCertificate peerCertificate() @propertyGet `peerCertificate` property. Returns: 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 #GD...
gio.types.TlsCertificateFlags peerCertificateErrors() @propertyGet `peerCertificateErrors` property. Returns: The errors noticed while verifying #GDtlsConnection:peer-certificate. Normally this should be 0, but it may not be if #GDtlsClientConnection:validatio...
gio.types.TlsProtocolVersion protocolVersion() @propertyGet `protocolVersion` property. Returns: The DTLS protocol version in use. See [gio.dtls_connection.DtlsConnection.getProtocolVersion].
gio.types.TlsRehandshakeMode rehandshakeMode() @propertyGet `rehandshakeMode` property. Returns: The rehandshaking mode. See [gio.dtls_connection.DtlsConnection.setRehandshakeMode].
void rehandshakeMode(gio.types.TlsRehandshakeMode propval) @propertySet `rehandshakeMode` property. Params: propval = The rehandshaking mode. See [gio.dtls_connection.DtlsConnection.setRehandshakeMode].
bool requireCloseNotify() @propertyGet `requireCloseNotify` property. Returns: Whether or not proper TLS close notification is required. See [gio.dtls_connection.DtlsConnection.setRequireCloseNotify].
void requireCloseNotify(bool propval) @propertySet `requireCloseNotify` property. Params: propval = Whether or not proper TLS close notification is required. See [gio.dtls_connection.DtlsConnection.setRequireCloseNotify].
bool close(gio.cancellable.Cancellable cancellable = null)Close the DTLS connection. This is equivalent to calling [gio.dtls_connection.DtlsConnection.shutdown] to shut down both sides of the connection.
void closeAsync(int ioPriority, gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)Asynchronously close the DTLS connection. See [gio.dtls_connection.DtlsConnection.close] for more information.
bool closeFinish(gio.async_result.AsyncResult result)Finish an asynchronous TLS close operation. See [gio.dtls_connection.DtlsConnection.close] for more information.
bool emitAcceptCertificate(gio.tls_certificate.TlsCertificate peerCert, gio.types.TlsCertificateFlags errors)Used by #GDtlsConnection implementations to emit the #GDtlsConnection::accept-certificate signal.
gio.tls_certificate.TlsCertificate getCertificate()Gets conn's certificate, as set by [gio.dtls_connection.DtlsConnection.setCertificate]. Returns: conn's certificate, or null
bool getChannelBindingData(gio.types.TlsChannelBindingType type, ref ubyte[] data)Query the TLS backend for TLS channel binding data of type for conn.
string getCiphersuiteName()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, ...
gio.tls_database.TlsDatabase getDatabase()Gets the certificate database that conn uses to verify peer certificates. See [gio.dtls_connection.DtlsConnection.setDatabase]. Returns: the certificate database that conn uses or null
gio.tls_interaction.TlsInteraction getInteraction()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 conne...
string getNegotiatedProtocol()Gets the name of the application-layer protocol negotiated during the handshake.
gio.tls_certificate.TlsCertificate getPeerCertificate()Gets conn's peer's certificate after the handshake has completed or failed. (It is not set during the emission of #GDtlsConnection::accept-certificate.) Returns: conn's peer's certificate, or null
gio.types.TlsCertificateFlags getPeerCertificateErrors()Gets the errors associated with validating conn's peer's certificate, after the handshake has completed or failed. (It is not set during the emission of #GDtlsConnection::accept-certificate.) Retur...
gio.types.TlsProtocolVersion getProtocolVersion()Returns the current DTLS protocol version, which may be [gio.types.TlsProtocolVersion.Unknown] if the connection has not handshaked, or has been closed, or if the TLS backend has implemented a prot...
gio.types.TlsRehandshakeMode getRehandshakeMode()Gets conn rehandshaking mode. See [gio.dtls_connection.DtlsConnection.setRehandshakeMode] for details. Returns: [gio.types.TlsRehandshakeMode.Safely]
bool getRequireCloseNotify()Tests whether or not conn expects a proper TLS close notification when the connection is closed. See [gio.dtls_connection.DtlsConnection.setRequireCloseNotify] for details. Returns: true if conn re...
bool handshake(gio.cancellable.Cancellable cancellable = null)Attempts a TLS handshake on conn.
void handshakeAsync(int ioPriority, gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)Asynchronously performs a TLS handshake on conn. See [gio.dtls_connection.DtlsConnection.handshake] for more information.
bool handshakeFinish(gio.async_result.AsyncResult result)Finish an asynchronous TLS handshake operation. See [gio.dtls_connection.DtlsConnection.handshake] for more information.
void setAdvertisedProtocols(string[] protocols = null)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 negotia...
void setCertificate(gio.tls_certificate.TlsCertificate 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.
void setDatabase(gio.tls_database.TlsDatabase database = null)Sets the certificate database that is used to verify peer certificates. This is set to the default database by default. See [gio.tls_backend.TlsBackend.getDefaultDatabase]. If set to null, then pee...
void setInteraction(gio.tls_interaction.TlsInteraction interaction = null)Set the object that will be used to interact with the user. It will be used for things like prompting the user for passwords.
void setRehandshakeMode(gio.types.TlsRehandshakeMode 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-handshak...
void setRequireCloseNotify(bool requireCloseNotify)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 p...
bool shutdown(bool shutdownRead, bool shutdownWrite, gio.cancellable.Cancellable cancellable = null)Shut down part or all of a DTLS connection.
void shutdownAsync(bool shutdownRead, bool shutdownWrite, int ioPriority, gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)Asynchronously shut down part or all of the DTLS connection. See [gio.dtls_connection.DtlsConnection.shutdown] for more information.
bool shutdownFinish(gio.async_result.AsyncResult result)Finish an asynchronous TLS shutdown operation. See [gio.dtls_connection.DtlsConnection.shutdown] for more information.
gulong connectAcceptCertificate(T)(T callback, Flag!"After" after = No.After)Connect to `AcceptCertificate` signal.
Methods
T baseSocket(gio.datagram_based.DatagramBased propval)Set `baseSocket` property. Params: propval = The #GDatagramBased that the connection wraps. Note that this may be any implementation of #GDatagramBased, not just a #GSocket. Returns: Builder instan...
T certificate(gio.tls_certificate.TlsCertificate propval)Set `certificate` property. Params: propval = The connection's certificate; see [gio.dtls_connection.DtlsConnection.setCertificate]. Returns: Builder instance for fluent chaining
T database(gio.tls_database.TlsDatabase propval)Set `database` property. Params: propval = The certificate database to use when verifying this TLS connection. If no certificate database is set, then the default database will be used. See [gio.tl...
T interaction(gio.tls_interaction.TlsInteraction propval)Set `interaction` property. Params: propval = 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 f...
T rehandshakeMode(gio.types.TlsRehandshakeMode propval)Set `rehandshakeMode` property. Params: propval = The rehandshaking mode. See [gio.dtls_connection.DtlsConnection.setRehandshakeMode]. Returns: Builder instance for fluent chaining
T requireCloseNotify(bool propval)Set `requireCloseNotify` property. Params: propval = Whether or not proper TLS close notification is required. See [gio.dtls_connection.DtlsConnection.setRequireCloseNotify]. Returns: Builder insta...