glibmm 2.82.0
|
TLS client-side connection. More...
#include <giomm/tlsclientconnection.h>
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. | |
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. | |
TLS client-side connection.
TlsClientConnection is the client-side subclass of TlsConnection, representing a client-side TLS connection.
|
protected |
You should derive from this class to use it.
|
noexcept |
|
overridenoexcept |
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.
source | A TlsClientConnection. |
|
static |
A create() convenience overload.
|
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.
base_io_stream | The IOStream to wrap. |
server_identity | The expected identity of the server. |
nullptr
on error.Glib::Error |
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.
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.
Glib::RefPtr< SocketConnectable > Gio::TlsClientConnection::get_server_identity | ( | ) |
Gets conn's expected server identity.
nullptr
if the expected identity is not known. Glib::RefPtr< const SocketConnectable > Gio::TlsClientConnection::get_server_identity | ( | ) | const |
Gets conn's expected server identity.
nullptr
if the expected identity is not known. Get the GType for this class, for use with the underlying GObject type system.
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.
Deprecated: 2.72: Do not attempt to ignore validation errors.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
|
noexcept |
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.
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.
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().
Deprecated: 2.72: 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
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().
Deprecated: 2.72: 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
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.
identity | A SocketConnectable describing the expected server identity. |
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.
Deprecated: 2.72: Do not attempt to ignore validation errors.
flags | The TlsCertificateFlags to use. |
|
related |
A Glib::wrap() method for this object.
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. |