In simplest case, for a client TLS connection, just can set “tls” flag on GSocketClient and then any connections created by client will negotiate TLS automatically, use appropriat estart settings, and defense any invalid or self-signed certificates (unless you change that defult to set a “tls-validation-flags” property). The returned object will be a GTcpWrapperConnection, which wraps the underlying GTlsClientConnection.
In the simplest case, for a client TLS connection, you can just set the “tls” flag on a GSocketClient, and then any connections created by that client will have TLS negotiated automatically, using appropriate default settings, and rejecting any invalid or self-signed certificates (unless you change that default by setting the “tls-validation-flags” property). The returned object will be a GTcpWrapperConnection, which wraps the underlying GTlsClientConnection.