Class: Gio::TlsConnection
Overview
The class structure for the GTls::Connection type.
Instance Method Summary collapse
-
#advertised_protocols ⇒ Gio::
The list of application-layer protocols that the connection advertises that it is willing to speak.
-
#advertised_protocols=(advertised_protocols) ⇒ Gio::
The list of application-layer protocols that the connection advertises that it is willing to speak.
-
#base_io_stream ⇒ Gio::IOStream
The #GIOStream that the connection wraps.
-
#base_io_stream=(base_io_stream) ⇒ Gio::IOStream
The #GIOStream that the connection wraps.
-
#certificate ⇒ Gio::TlsCertificate
The connection's certificate; see g_tls_connection_set_certificate().
-
#certificate=(certificate) ⇒ Gio::TlsCertificate
The connection's certificate; see g_tls_connection_set_certificate().
-
#ciphersuite_name ⇒ String
The name of the TLS ciphersuite in use.
-
#ciphersuite_name=(ciphersuite_name) ⇒ String
The name of the TLS ciphersuite in use.
-
#database ⇒ Gio::TlsDatabase
The certificate database to use when verifying this TLS connection.
-
#database=(database) ⇒ Gio::TlsDatabase
The certificate database to use when verifying this TLS connection.
-
#emit_accept_certificate(peer_cert, errors) ⇒ Boolean
Used by GTls::Connection implementations to emit the GTls::Connection::accept-certificate signal.
-
#get_channel_binding_data(type, data) ⇒ Boolean
Query the TLS backend for TLS channel binding data of type for conn.
-
#handshake(cancellable) ⇒ Boolean
Attempts a TLS handshake on conn.
-
#handshake_async(io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously performs a TLS handshake on conn.
-
#handshake_finish(result) ⇒ Boolean
Finish an asynchronous TLS handshake operation.
-
#interaction ⇒ Gio::TlsInteraction
A GTls::Interaction object to be used when the connection or certificate database need to interact with the user.
-
#interaction=(interaction) ⇒ Gio::TlsInteraction
A GTls::Interaction object to be used when the connection or certificate database need to interact with the user.
-
#negotiated_protocol ⇒ String
The application-layer protocol negotiated during the TLS handshake.
-
#negotiated_protocol=(negotiated_protocol) ⇒ String
The application-layer protocol negotiated during the TLS handshake.
-
#peer_certificate ⇒ Gio::TlsCertificate
The connection's peer's certificate, after the TLS handshake has completed or failed.
-
#peer_certificate=(peer_certificate) ⇒ Gio::TlsCertificate
The connection's peer's certificate, after the TLS handshake has completed or failed.
-
#peer_certificate_errors ⇒ Gio::TlsCertificateFlags
The errors noticed while verifying GTls::Connection:peer-certificate.
-
#peer_certificate_errors=(peer_certificate_errors) ⇒ Gio::TlsCertificateFlags
The errors noticed while verifying GTls::Connection:peer-certificate.
-
#protocol_version ⇒ Gio::TlsProtocolVersion
The TLS protocol version in use.
-
#protocol_version=(protocol_version) ⇒ Gio::TlsProtocolVersion
The TLS protocol version in use.
-
#rehandshake_mode ⇒ Gio::TlsRehandshakeMode
The rehandshaking mode.
-
#rehandshake_mode=(rehandshake_mode) ⇒ Gio::TlsRehandshakeMode
The rehandshaking mode.
-
#require_close_notify ⇒ Boolean
Tests whether or not conn expects a proper TLS close notification when the connection is closed.
-
#require_close_notify=(require_close_notify) ⇒ Boolean
Whether or not proper TLS close notification is required.
-
#require_close_notify? ⇒ Boolean
Whether or not proper TLS close notification is required.
-
#use_system_certdb ⇒ Boolean
Gets whether conn uses the system certificate database to verify peer certificates.
-
#use_system_certdb=(use_system_certdb) ⇒ Boolean
Whether or not the system certificate database will be used to verify peer certificates.
-
#use_system_certdb? ⇒ Boolean
Whether or not the system certificate database will be used to verify peer certificates.
Methods inherited from IOStream
#clear_pending, #close, #close_async, #close_finish, #closed=, #closed?, #has_pending, #input_stream, #input_stream=, #is_closed, #output_stream, #output_stream=, #set_pending, #splice_async, splice_finish
Instance Method Details
#advertised_protocols ⇒ Gio::
The list of application-layer protocols that the connection advertises that it is willing to speak. See g_tls_connection_set_advertised_protocols().
#advertised_protocols=(advertised_protocols) ⇒ Gio::
The list of application-layer protocols that the connection advertises that it is willing to speak. See g_tls_connection_set_advertised_protocols().
#base_io_stream ⇒ Gio::IOStream
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.
#base_io_stream=(base_io_stream) ⇒ Gio::IOStream
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.
#certificate ⇒ Gio::TlsCertificate
The connection's certificate; see g_tls_connection_set_certificate().
#certificate=(certificate) ⇒ Gio::TlsCertificate
The connection's certificate; see g_tls_connection_set_certificate().
#ciphersuite_name ⇒ String
The name of the TLS ciphersuite in use. See g_tls_connection_get_ciphersuite_name().
#ciphersuite_name=(ciphersuite_name) ⇒ String
The name of the TLS ciphersuite in use. See g_tls_connection_get_ciphersuite_name().
#database ⇒ Gio::TlsDatabase
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().
When using a non-default database, GTls::Connection must fall back to using the GTls::Database to perform certificate verification using g_tls_database_verify_chain(), which means certificate verification will not be able to make use of TLS session context. This may be less secure. For example, if you create your own GTls::Database that just wraps the default GTls::Database, you might expect that you have not changed anything, but this is not true because you may have altered the behavior of GTls::Connection by causing it to use g_tls_database_verify_chain(). See the documentation of g_tls_database_verify_chain() for more details on specific security checks that may not be performed. Accordingly, setting a non-default database is discouraged except for specialty applications with unusual security requirements.
#database=(database) ⇒ Gio::TlsDatabase
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().
When using a non-default database, GTls::Connection must fall back to using the GTls::Database to perform certificate verification using g_tls_database_verify_chain(), which means certificate verification will not be able to make use of TLS session context. This may be less secure. For example, if you create your own GTls::Database that just wraps the default GTls::Database, you might expect that you have not changed anything, but this is not true because you may have altered the behavior of GTls::Connection by causing it to use g_tls_database_verify_chain(). See the documentation of g_tls_database_verify_chain() for more details on specific security checks that may not be performed. Accordingly, setting a non-default database is discouraged except for specialty applications with unusual security requirements.
#emit_accept_certificate(peer_cert, errors) ⇒ Boolean
Used by GTls::Connection implementations to emit the GTls::Connection::accept-certificate signal.
#get_channel_binding_data(type, data) ⇒ Boolean
Query the TLS backend for TLS channel binding data of type for conn.
This call retrieves TLS channel binding data as specified in RFC 5056, RFC 5929, and related RFCs. The binding data is returned in data. The data is resized by the callee using GByte::Array buffer management and will be freed when the data is destroyed by g_byte_array_unref(). If data is nil, it will only check whether TLS backend is able to fetch the data (e.g. whether type is supported by the TLS backend). It does not guarantee that the data will be available though. That could happen if TLS connection does not support type or the binding data is not available yet due to additional negotiation or input required.
#handshake(cancellable) ⇒ Boolean
Attempts a TLS handshake on conn.
On the client side, it is never necessary to call this method; although the connection needs to perform a handshake after connecting (or after sending a "STARTTLS"-type command), GTls::Connection will handle this for you automatically when you try to send or receive data on the connection. You can call g_tls_connection_handshake() manually if you want to know whether the initial handshake succeeded or failed (as opposed to just immediately trying to use conn to read or write, in which case, if it fails, it may not be possible to tell if it failed before or after completing the handshake), but beware that servers may reject client authentication after the handshake has completed, so a successful handshake does not indicate the connection will be usable.
Likewise, on the server side, although a handshake is necessary at the beginning of the communication, you do not need to call this function explicitly unless you want clearer error reporting.
Previously, calling g_tls_connection_handshake() after the initial handshake would trigger a rehandshake; however, this usage was deprecated in GLib 2.60 because rehandshaking was removed from the TLS protocol in TLS 1.3. Since GLib 2.64, calling this function after the initial handshake will no longer do anything.
When using a GTls::Connection created by #GSocketClient, the GSocket::Client performs the initial handshake, so calling this function manually is not recommended.
GTls::Connection::accept_certificate may be emitted during the handshake.
#handshake_async(io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously performs a TLS handshake on conn. See g_tls_connection_handshake() for more information.
#handshake_finish(result) ⇒ Boolean
Finish an asynchronous TLS handshake operation. See g_tls_connection_handshake() for more information. case error will be set.
#interaction ⇒ Gio::TlsInteraction
A GTls::Interaction 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.
#interaction=(interaction) ⇒ Gio::TlsInteraction
A GTls::Interaction 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.
#negotiated_protocol ⇒ String
The application-layer protocol negotiated during the TLS handshake. See g_tls_connection_get_negotiated_protocol().
#negotiated_protocol=(negotiated_protocol) ⇒ String
The application-layer protocol negotiated during the TLS handshake. See g_tls_connection_get_negotiated_protocol().
#peer_certificate ⇒ Gio::TlsCertificate
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 GTls::Connection::accept-certificate.
(You can watch for a #GObject::notify signal on this property to detect when a handshake has occurred.)
#peer_certificate=(peer_certificate) ⇒ Gio::TlsCertificate
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 GTls::Connection::accept-certificate.
(You can watch for a #GObject::notify signal on this property to detect when a handshake has occurred.)
#peer_certificate_errors ⇒ Gio::TlsCertificateFlags
The errors noticed while verifying GTls::Connection:peer-certificate. Normally this should be 0, but it may not be if GTls::ClientConnection:validation-flags is not %G_TLS_CERTIFICATE_VALIDATE_ALL, or if GTls::Connection::accept-certificate overrode the default behavior.
GLib guarantees that if certificate verification fails, at least one error will be set, but it does not guarantee that all possible errors will be set. Accordingly, you may not safely decide to ignore any particular type of error. For example, it would be incorrect to mask %G_TLS_CERTIFICATE_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.
#peer_certificate_errors=(peer_certificate_errors) ⇒ Gio::TlsCertificateFlags
The errors noticed while verifying GTls::Connection:peer-certificate. Normally this should be 0, but it may not be if GTls::ClientConnection:validation-flags is not %G_TLS_CERTIFICATE_VALIDATE_ALL, or if GTls::Connection::accept-certificate overrode the default behavior.
GLib guarantees that if certificate verification fails, at least one error will be set, but it does not guarantee that all possible errors will be set. Accordingly, you may not safely decide to ignore any particular type of error. For example, it would be incorrect to mask %G_TLS_CERTIFICATE_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.
#protocol_version ⇒ Gio::TlsProtocolVersion
The TLS protocol version in use. See g_tls_connection_get_protocol_version().
#protocol_version=(protocol_version) ⇒ Gio::TlsProtocolVersion
The TLS protocol version in use. See g_tls_connection_get_protocol_version().
#rehandshake_mode ⇒ Gio::TlsRehandshakeMode
The rehandshaking mode. See g_tls_connection_set_rehandshake_mode().
#rehandshake_mode=(rehandshake_mode) ⇒ Gio::TlsRehandshakeMode
The rehandshaking mode. See g_tls_connection_set_rehandshake_mode().
#require_close_notify ⇒ Boolean
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. notification.
#require_close_notify=(require_close_notify) ⇒ Boolean
Whether or not proper TLS close notification is required. See g_tls_connection_set_require_close_notify().
#require_close_notify? ⇒ Boolean
Whether or not proper TLS close notification is required. See g_tls_connection_set_require_close_notify().
#use_system_certdb ⇒ Boolean
Gets whether conn uses the system certificate database to verify peer certificates. See g_tls_connection_set_use_system_certdb().
#use_system_certdb=(use_system_certdb) ⇒ Boolean
Whether or not the system certificate database will be used to verify peer certificates. See g_tls_connection_set_use_system_certdb().
#use_system_certdb? ⇒ Boolean
Whether or not the system certificate database will be used to verify peer certificates. See g_tls_connection_set_use_system_certdb().