Class

GioTlsConnection

Description [src]

abstract class Gio.TlsConnection : Gio.IOStream {
  parent_instance: GIOStream,
  priv: GTlsConnectionPrivate*
}

GTlsConnection is the base TLS connection class type, which wraps a GIOStream and provides TLS encryption on top of it. Its subclasses, GTlsClientConnection and GTlsServerConnection, implement client-side and server-side TLS, respectively.

For DTLS (Datagram TLS) support, see GDtlsConnection.

Available since:2.28

Hierarchy

hierarchy this GTlsConnection ancestor_0 GIOStream ancestor_0--this ancestor_1 GObject ancestor_1--ancestor_0

Ancestors

Instance methods

g_tls_connection_emit_accept_certificate

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

Available since: 2.28

g_tls_connection_get_certificate

Gets conns certificate, as set by g_tls_connection_set_certificate().

Available since: 2.28

g_tls_connection_get_channel_binding_data

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

Available since: 2.66

g_tls_connection_get_ciphersuite_name

Returns the name of the current TLS 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.

Available since: 2.70

g_tls_connection_get_database

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

Available since: 2.30

g_tls_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.

Available since: 2.30

g_tls_connection_get_negotiated_protocol

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

Available since: 2.60

g_tls_connection_get_peer_certificate

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

Available since: 2.28

g_tls_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 GTlsConnection::accept-certificate.)

Available since: 2.28

g_tls_connection_get_protocol_version

Returns the current TLS 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.

Available since: 2.70

g_tls_connection_get_rehandshake_mode

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

Available since: 2.28

Deprecated since: 2.60.

g_tls_connection_get_require_close_notify

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

Available since: 2.28

g_tls_connection_get_use_system_certdb

Gets whether conn uses the system certificate database to verify peer certificates. See g_tls_connection_set_use_system_certdb().

Deprecated since: 2.30

g_tls_connection_handshake

Attempts a TLS handshake on conn.

Available since: 2.28

g_tls_connection_handshake_async

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

Available since: 2.28

g_tls_connection_handshake_finish

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

Available since: 2.28

g_tls_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_tls_connection_get_negotiated_protocol() to find the negotiated protocol after the handshake. Specifying NULL for the the value of protocols will disable ALPN negotiation.

Available since: 2.60

g_tls_connection_set_certificate

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

Available since: 2.28

g_tls_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 GTlsConnection::accept-certificate will always be emitted on client-side connections, unless that bit is not set in GTlsClientConnection:validation-flags).

Available since: 2.30

g_tls_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.

Available since: 2.30

g_tls_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.

Available since: 2.28

Deprecated since: 2.60.

g_tls_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).

Available since: 2.28

g_tls_connection_set_use_system_certdb

Sets whether conn uses the system certificate database to verify peer certificates. This is TRUE by default. If set to FALSE, then peer certificate validation will always set the G_TLS_CERTIFICATE_UNKNOWN_CA error (meaning GTlsConnection::accept-certificate will always be emitted on client-side connections, unless that bit is not set in GTlsClientConnection:validation-flags).

Deprecated since: 2.30

Methods inherited from GIOStream (10)
g_io_stream_clear_pending

Clears the pending flag on stream.

Available since: 2.22

g_io_stream_close

Closes the stream, releasing resources related to it. This will also close the individual input and output streams, if they are not already closed.

Available since: 2.22

g_io_stream_close_async

Requests an asynchronous close of the stream, releasing resources related to it. When the operation is finished callback will be called. You can then call g_io_stream_close_finish() to get the result of the operation.

Available since: 2.22

g_io_stream_close_finish

Closes a stream.

Available since: 2.22

g_io_stream_get_input_stream

Gets the input stream for this object. This is used for reading.

Available since: 2.22

g_io_stream_get_output_stream

Gets the output stream for this object. This is used for writing.

Available since: 2.22

g_io_stream_has_pending

Checks if a stream has pending actions.

Available since: 2.22

g_io_stream_is_closed

Checks if a stream is closed.

Available since: 2.22

g_io_stream_set_pending

Sets stream to have actions pending. If the pending flag is already set or stream is closed, it will return FALSE and set error.

Available since: 2.22

g_io_stream_splice_async

Asynchronously splice the output stream of stream1 to the input stream of stream2, and splice the output stream of stream2 to the input stream of stream1.

Available since: 2.28

Methods inherited from GObject (43)

Properties

Gio.TlsConnection:advertised-protocols

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

Available since: 2.60

Gio.TlsConnection:base-io-stream

The GIOStream that the connection wraps. The connection holds a reference to this stream, and may run operations on the stream from other threads throughout its lifetime. Consequently, after the GIOStream has been constructed, application code may only run its own operations on this stream when no GIOStream operations are running.

Available since: 2.28

Gio.TlsConnection:certificate

The connection’s certificate; see g_tls_connection_set_certificate().

Available since: 2.28

Gio.TlsConnection:ciphersuite-name

The name of the TLS ciphersuite in use. See g_tls_connection_get_ciphersuite_name().

Available since: 2.70

Gio.TlsConnection: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().

Available since: 2.30

Gio.TlsConnection: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.

Available since: 2.30

Gio.TlsConnection:negotiated-protocol

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

Available since: 2.60

Gio.TlsConnection: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 GTlsConnection::accept-certificate.

Available since: 2.28

Gio.TlsConnection:peer-certificate-errors

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

Available since: 2.28

Gio.TlsConnection:protocol-version

The TLS protocol version in use. See g_tls_connection_get_protocol_version().

Available since: 2.70

Gio.TlsConnection:rehandshake-mode

The rehandshaking mode. See g_tls_connection_set_rehandshake_mode().

Available since: 2.28

Deprecated since: 2.60

Gio.TlsConnection:require-close-notify

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

Available since: 2.28

Gio.TlsConnection:use-system-certdb

Whether or not the system certificate database will be used to verify peer certificates. See g_tls_connection_set_use_system_certdb().

Deprecated since: 2.30

Properties inherited from GIOStream (3)
Gio.IOStream:closed
No description available.
Gio.IOStream:input-stream
No description available.
Gio.IOStream:output-stream
No description available.

Signals

Gio.TlsConnection::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.

Available since: 2.28

Signals inherited from GObject (1)

Class structure

struct GioTlsConnectionClass {
  GIOStreamClass parent_class;
  gboolean (* accept_certificate) (
    GTlsConnection* connection,
    GTlsCertificate* peer_cert,
    GTlsCertificateFlags errors
  );
  gboolean (* handshake) (
    GTlsConnection* conn,
    GCancellable* cancellable,
    GError** error
  );
  void (* handshake_async) (
    GTlsConnection* conn,
    int io_priority,
    GCancellable* cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data
  );
  gboolean (* handshake_finish) (
    GTlsConnection* conn,
    GAsyncResult* result,
    GError** error
  );
  gboolean (* get_binding_data) (
    GTlsConnection* conn,
    GTlsChannelBindingType type,
    GByteArray* data,
    GError** error
  );
  const gchar* (* get_negotiated_protocol) (
    GTlsConnection* conn
  );
  
}
Class members
parent_class
GIOStreamClass
 

The parent class.

accept_certificate
gboolean (* accept_certificate) (
    GTlsConnection* connection,
    GTlsCertificate* peer_cert,
    GTlsCertificateFlags errors
  )
  No description available.
handshake
gboolean (* handshake) (
    GTlsConnection* conn,
    GCancellable* cancellable,
    GError** error
  )
  No description available.
handshake_async
void (* handshake_async) (
    GTlsConnection* conn,
    int io_priority,
    GCancellable* cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data
  )
  No description available.
handshake_finish
gboolean (* handshake_finish) (
    GTlsConnection* conn,
    GAsyncResult* result,
    GError** error
  )
  No description available.
get_binding_data
gboolean (* get_binding_data) (
    GTlsConnection* conn,
    GTlsChannelBindingType type,
    GByteArray* data,
    GError** error
  )
  No description available.
get_negotiated_protocol
const gchar* (* get_negotiated_protocol) (
    GTlsConnection* conn
  )
  No description available.

Virtual methods

Gio.TlsConnectionClass.accept_certificate
No description available.
Gio.TlsConnectionClass.get_binding_data
No description available.
Gio.TlsConnectionClass.get_negotiated_protocol

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

Available since: 2.60

Gio.TlsConnectionClass.handshake

Attempts a TLS handshake on conn.

Available since: 2.28

Gio.TlsConnectionClass.handshake_async

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

Available since: 2.28

Gio.TlsConnectionClass.handshake_finish

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

Available since: 2.28