glibmm 2.88.0

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gio::TlsClientConnection Class Reference

TLS client-side connection. More...

`#include <giomm/tlsclientconnection.h>`

Inheritance diagram for Gio::TlsClientConnection:
[legend]

## Public Member Functions
| TlsClientConnection (TlsClientConnection &&src) noexcept
TlsClientConnection & | operator= (TlsClientConnection &&src) noexcept
| ~TlsClientConnection () noexcept override
GTlsClientConnection * | gobj ()
| Provides access to the underlying C GObject.
const GTlsClientConnection * | gobj () const
| Provides access to the underlying C GObject.
void | set_server_identity (const Glib::RefPtr< SocketConnectable > & identity)
| Sets conn's expected server identity, which is used both to tell servers on virtual hosts which certificate to present, and also to let conn know what name to look for in the certificate when performing Gio::TlsCertificateFlags::BAD_IDENTITY validation, if enabled.
Glib::RefPtr< SocketConnectable > | get_server_identity ()
| Gets conn's expected server identity.
Glib::RefPtr< const SocketConnectable > | get_server_identity () const
| Gets conn's expected server identity.
void | set_validation_flags (TlsCertificateFlags flags)
| Sets conn's validation flags, to override the default set of checks performed when validating a server certificate.
TlsCertificateFlags | get_validation_flags () const
| Gets conn's validation flags.
std::vector< Glib::RefPtr< Glib::ByteArray > > | get_accepted_cas ()
| Gets the list of distinguished names of the Certificate Authorities that the server will accept certificates from.
std::vector< Glib::RefPtr< const Glib::ByteArray > > | get_accepted_cas () const
| Gets the list of distinguished names of the Certificate Authorities that the server will accept certificates from.
void | copy_session_state (const Glib::RefPtr< TlsClientConnection > &source)
| Possibly copies session state from one connection to another, for use in TLS session resumption.
Glib::PropertyProxy< Glib::RefPtr< SocketConnectable > > | property_server_identity ()
| A SocketConnectable describing the identity of the server that is expected on the other end of the connection.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< SocketConnectable > > | property_server_identity () const
| A SocketConnectable describing the identity of the server that is expected on the other end of the connection.
Glib::PropertyProxy< TlsCertificateFlags > | property_validation_flags ()
| What steps to perform when validating a certificate received from a server.
Glib::PropertyProxy_ReadOnly< TlsCertificateFlags > | property_validation_flags () const
| What steps to perform when validating a certificate received from a server.
Public Member Functions inherited from Glib::Interface
| Interface ()
| A Default constructor.
| Interface (Interface &&src) noexcept
Interface & | operator= (Interface &&src) noexcept
| Interface (const Glib::Interface_Class &interface_class)
| Called by constructors of derived classes.
| Interface (GObject *castitem)
| Called by constructors of derived classes.
| ~Interface () noexcept override
| Interface (const Interface &)=delete
Interface & | operator= (const Interface &)=delete
GObject * | gobj ()
const GObject * | gobj () const
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
void | set_property_value (const Glib::ustring & property_name, const Glib::ValueBase & value)
| You probably want to use a specific property_*() accessor method instead.
void | get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const
| You probably want to use a specific property_*() accessor method instead.
template<class PropertyType >
void | set_property (const Glib::ustring & property_name, const PropertyType & value)
| You probably want to use a specific property_*() accessor method instead.
template<class PropertyType >
void | get_property (const Glib::ustring & property_name, PropertyType & value) const
| You probably want to use a specific property_*() accessor method instead.
template<class PropertyType >
PropertyType | get_property (const Glib::ustring & property_name) const
| You probably want to use a specific property_*() accessor method instead.
sigc::connection | connect_property_changed (const Glib::ustring & property_name, const sigc::slot< void()> & slot)
| You can use the signal_changed() signal of the property proxy instead.
sigc::connection | connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> && slot)
| You can use the signal_changed() signal of the property proxy instead.
void | freeze_notify ()
| Increases the freeze count on object.
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify().
virtual void | reference () const
| Increment the reference count for this object.
virtual void | unreference () const
| Decrement the reference count for this object.
GObject * | gobj ()
| Provides access to the underlying C GObject.
const GObject * | gobj () const
| Provides access to the underlying C GObject.
GObject * | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access.
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src) noexcept
| ~trackable ()
void | add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src) noexcept
void | remove_destroy_notify_callback (notifiable *data) const

## Static Public Member Functions
static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.
static Glib::RefPtr< TlsClientConnectionImpl > | create (const Glib::RefPtr< IOStream > &base_io_stream, const Glib::RefPtr< const SocketConnectable > &server_identity)
| Creates a new TlsClientConnection wrapping base_io_stream (which must have pollable input and output streams) which is assumed to communicate with the server identified by server_identity.
static Glib::RefPtr< TlsClientConnectionImpl > | create (const Glib::RefPtr< IOStream > &base_io_stream)
| A create() convenience overload.

## Protected Member Functions
| TlsClientConnection ()
| You should derive from this class to use it.
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor.
| ObjectBase (const char *custom_type_name)
| A derived constructor always overrides this choice.
| ObjectBase (const std::type_info &custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually.
| ObjectBase (ObjectBase &&src) noexcept
ObjectBase & | operator= (ObjectBase &&src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject *castitem)
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)

## Related Symbols
(Note that these are not member symbols.)
Glib::RefPtr< Gio::TlsClientConnection > | wrap (GTlsClientConnection *object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Additional Inherited Members
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify
Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify | func_destroy_notify

## Detailed Description

TLS client-side connection.

TlsClientConnection is the client-side subclass of TlsConnection, representing a client-side TLS connection.

Since glibmm 2.36:

## Constructor & Destructor Documentation

## ◆ TlsClientConnection() [1/2]

Gio::TlsClientConnection::TlsClientConnection | ( |  | ) |
| protected

You should derive from this class to use it.

## ◆ TlsClientConnection() [2/2]

Gio::TlsClientConnection::TlsClientConnection | ( | TlsClientConnection && | src | ) |
| noexcept

## ◆ ~TlsClientConnection()

Gio::TlsClientConnection::~TlsClientConnection | ( |  | ) |
| override noexcept

## Member Function Documentation

## ◆ add_interface()

static void Gio::TlsClientConnection::add_interface | ( | GType | gtype_implementer | ) |
| static

## ◆ copy_session_state()

void Gio::TlsClientConnection::copy_session_state | ( | const Glib::RefPtr< TlsClientConnection > & | source | ) |

Possibly copies session state from one connection to another, for use in TLS session resumption.

This is not normally needed, but may be used when the same session needs to be used between different endpoints, as is required by some protocols, such as FTP over TLS. source should have already completed a handshake and, since TLS 1.3, it should have been used to read data at least once. conn should not have completed a handshake.

It is not possible to know whether a call to this function will actually do anything. Because session resumption is normally used only for performance benefit, the TLS backend might not implement this function. Even if implemented, it may not actually succeed in allowing conn to resume source's TLS session, because the server may not have sent a session resumption token to source, or it may refuse to accept the token from conn. There is no way to know whether a call to this function is actually successful.

Using this function is not required to benefit from session resumption. If the TLS backend supports session resumption, the session will be resumed automatically if it is possible to do so without weakening the privacy guarantees normally provided by TLS, without need to call this function. For example, with TLS 1.3, a session ticket will be automatically copied from any TlsClientConnection that has previously received session tickets from the server, provided a ticket is available that has not previously been used for session resumption, since session ticket reuse would be a privacy weakness. Using this function causes the ticket to be copied without regard for privacy considerations.

Since glibmm 2.46:

Parameters

  source | A TlsClientConnection.

## ◆ create() [1/2]

static Glib::RefPtr< TlsClientConnectionImpl > Gio::TlsClientConnection::create | ( | const Glib::RefPtr< IOStream > & | base_io_stream | ) |
| static

A create() convenience overload.

## ◆ create() [2/2]

static Glib::RefPtr< TlsClientConnectionImpl > Gio::TlsClientConnection::create | ( | const Glib::RefPtr< IOStream > & | base_io_stream,
|  | const Glib::RefPtr< const SocketConnectable > & | server_identity
| ) |  |
| static

Creates a new TlsClientConnection wrapping base_io_stream (which must have pollable input and output streams) which is assumed to communicate with the server identified by server_identity.

See the documentation for TlsConnection::property_base_io_stream() for restrictions on when application code can run operations on the base_io_stream after this function has returned.

Since glibmm 2.28:

Parameters

  base_io_stream | The IOStream to wrap.
  server_identity | The expected identity of the server.

Returns
  The new TlsClientConnection, or `nullptr` on error.

Exceptions

  Glib::Error |

## ◆ get_accepted_cas() [1/2]

std::vector< Glib::RefPtr< Glib::ByteArray > > Gio::TlsClientConnection::get_accepted_cas | ( |  | ) |

Gets the list of distinguished names of the Certificate Authorities that the server will accept certificates from.

This will be set during the TLS handshake if the server requests a certificate. Otherwise, it will be `nullptr`.

Each item in the list is a ByteArray which contains the complete subject DN of the certificate authority.

Since glibmm 2.28:

Returns
  The list of CA DNs.

## ◆ get_accepted_cas() [2/2]

std::vector< Glib::RefPtr< const Glib::ByteArray > > Gio::TlsClientConnection::get_accepted_cas | ( |  | ) | const

Gets the list of distinguished names of the Certificate Authorities that the server will accept certificates from.

This will be set during the TLS handshake if the server requests a certificate. Otherwise, it will be `nullptr`.

Each item in the list is a ByteArray which contains the complete subject DN of the certificate authority.

Since glibmm 2.28:

Returns
  The list of CA DNs.

## ◆ get_server_identity() [1/2]

Glib::RefPtr< SocketConnectable > Gio::TlsClientConnection::get_server_identity | ( |  | ) |

Gets conn's expected server identity.

Since glibmm 2.28:

Returns
  A SocketConnectable describing the expected server identity, or `nullptr` if the expected identity is not known.

## ◆ get_server_identity() [2/2]

Glib::RefPtr< const SocketConnectable > Gio::TlsClientConnection::get_server_identity | ( |  | ) | const

Gets conn's expected server identity.

Since glibmm 2.28:

Returns
  A SocketConnectable describing the expected server identity, or `nullptr` if the expected identity is not known.

## ◆ get_type()

static GType Gio::TlsClientConnection::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ get_validation_flags()

TlsCertificateFlags Gio::TlsClientConnection::get_validation_flags | ( |  | ) | const

Gets conn's validation flags.

This function does not work as originally designed and is impossible to use correctly. See TlsClientConnection::property_validation_flags() for more information.

Since glibmm 2.28:

Deprecated: 2.72: Do not attempt to ignore validation errors.

Deprecated:
  Do not attempt to ignore validation errors.

Returns
  The validation flags.

## ◆ gobj() [1/2]

GTlsClientConnection * Gio::TlsClientConnection::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GTlsClientConnection * Gio::TlsClientConnection::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ operator=()

TlsClientConnection & Gio::TlsClientConnection::operator= | ( | TlsClientConnection && | src | ) |
| noexcept

## ◆ property_server_identity() [1/2]

Glib::PropertyProxy< Glib::RefPtr< SocketConnectable > > Gio::TlsClientConnection::property_server_identity | ( |  | ) |

A SocketConnectable describing the identity of the server that is expected on the other end of the connection.

If the Gio::TlsCertificateFlags::BAD_IDENTITY flag is set in TlsClientConnection::property_validation_flags(), this object will be used to determine the expected identify of the remote end of the connection; if TlsClientConnection::property_server_identity() is not set, or does not match the identity presented by the server, then the Gio::TlsCertificateFlags::BAD_IDENTITY validation will fail.

In addition to its use in verifying the server certificate, this is also used to give a hint to the server about what certificate we expect, which is useful for servers that serve virtual hosts.

Since glibmm 2.28:

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_server_identity() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< SocketConnectable > > Gio::TlsClientConnection::property_server_identity | ( |  | ) | const

A SocketConnectable describing the identity of the server that is expected on the other end of the connection.

If the Gio::TlsCertificateFlags::BAD_IDENTITY flag is set in TlsClientConnection::property_validation_flags(), this object will be used to determine the expected identify of the remote end of the connection; if TlsClientConnection::property_server_identity() is not set, or does not match the identity presented by the server, then the Gio::TlsCertificateFlags::BAD_IDENTITY validation will fail.

In addition to its use in verifying the server certificate, this is also used to give a hint to the server about what certificate we expect, which is useful for servers that serve virtual hosts.

Since glibmm 2.28:

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_validation_flags() [1/2]

Glib::PropertyProxy< TlsCertificateFlags > Gio::TlsClientConnection::property_validation_flags | ( |  | ) |

What steps to perform when validating a certificate received from a server.

Server certificates that fail to validate in any of the ways indicated here will be rejected unless the application overrides the default via TlsConnection::signal_accept_certificate().

GLib guarantees that if certificate verification fails, at least one flag will be set, but it does not guarantee that all possible flags will be set. Accordingly, you may not safely decide to ignore any particular type of error. For example, it would be incorrect to mask Gio::TlsCertificateFlags::EXPIRED if you want to allow expired certificates, because this could potentially be the only error flag set even if other problems exist with the certificate. Therefore, there is no safe way to use this property. This is not a horrible problem, though, because you should not be attempting to ignore validation errors anyway. If you really must ignore TLS certificate errors, connect to TlsConnection::signal_accept_certificate().

Since glibmm 2.28:

Deprecated: 2.72: Do not attempt to ignore validation errors.

Deprecated:
  Do not attempt to ignore validation errors.

Default value: Gio::TlsCertificateFlags::UNKNOWN_CA | Gio::TlsCertificateFlags::BAD_IDENTITY | Gio::TlsCertificateFlags::NOT_ACTIVATED | Gio::TlsCertificateFlags::EXPIRED | Gio::TlsCertificateFlags::REVOKED | Gio::TlsCertificateFlags::INSECURE | Gio::TlsCertificateFlags::GENERIC_ERROR

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_validation_flags() [2/2]

Glib::PropertyProxy_ReadOnly< TlsCertificateFlags > Gio::TlsClientConnection::property_validation_flags | ( |  | ) | const

What steps to perform when validating a certificate received from a server.

Server certificates that fail to validate in any of the ways indicated here will be rejected unless the application overrides the default via TlsConnection::signal_accept_certificate().

GLib guarantees that if certificate verification fails, at least one flag will be set, but it does not guarantee that all possible flags will be set. Accordingly, you may not safely decide to ignore any particular type of error. For example, it would be incorrect to mask Gio::TlsCertificateFlags::EXPIRED if you want to allow expired certificates, because this could potentially be the only error flag set even if other problems exist with the certificate. Therefore, there is no safe way to use this property. This is not a horrible problem, though, because you should not be attempting to ignore validation errors anyway. If you really must ignore TLS certificate errors, connect to TlsConnection::signal_accept_certificate().

Since glibmm 2.28:

Deprecated: 2.72: Do not attempt to ignore validation errors.

Deprecated:
  Do not attempt to ignore validation errors.

Default value: Gio::TlsCertificateFlags::UNKNOWN_CA | Gio::TlsCertificateFlags::BAD_IDENTITY | Gio::TlsCertificateFlags::NOT_ACTIVATED | Gio::TlsCertificateFlags::EXPIRED | Gio::TlsCertificateFlags::REVOKED | Gio::TlsCertificateFlags::INSECURE | Gio::TlsCertificateFlags::GENERIC_ERROR

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ set_server_identity()

void Gio::TlsClientConnection::set_server_identity | ( | const Glib::RefPtr< SocketConnectable > & | identity | ) |

Sets conn's expected server identity, which is used both to tell servers on virtual hosts which certificate to present, and also to let conn know what name to look for in the certificate when performing Gio::TlsCertificateFlags::BAD_IDENTITY validation, if enabled.

Since glibmm 2.28:

Parameters

  identity | A SocketConnectable describing the expected server identity.

## ◆ set_validation_flags()

void Gio::TlsClientConnection::set_validation_flags | ( | TlsCertificateFlags | flags | ) |

Sets conn's validation flags, to override the default set of checks performed when validating a server certificate.

By default, Gio::TlsCertificateFlags::VALIDATE_ALL is used.

This function does not work as originally designed and is impossible to use correctly. See TlsClientConnection::property_validation_flags() for more information.

Since glibmm 2.28:

Deprecated: 2.72: Do not attempt to ignore validation errors.

Deprecated:
  Do not attempt to ignore validation errors.

Parameters

  flags | The TlsCertificateFlags to use.

## Friends And Related Symbol Documentation

## ◆ wrap()

Glib::RefPtr< Gio::TlsClientConnection > wrap | ( | GTlsClientConnection * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.