### Class

# Gio TlsInteraction

since: 2.30

#### Description [src]

    class Gio.TlsInteraction : GObject.Object
    {
      /* No available fields */
    }

`GTlsInteraction` provides a mechanism for the TLS connection and database code to interact with the user. It can be used to ask the user for passwords.

To use a `GTlsInteraction` with a TLS connection use `g_tls_connection_set_interaction()`.

Callers should instantiate a derived class that implements the various interaction methods to show the required dialogs.

Callers should use the ‘invoke’ functions like `g_tls_interaction_invoke_ask_password()` to run interaction methods. These functions make sure that the interaction is invoked in the main loop and not in the current thread, if the current thread is not running the main loop.

Derived classes can choose to implement whichever interactions methods they’d like to support by overriding those virtual methods in their class initialization function. Any interactions not implemented will return `G_TLS_INTERACTION_UNHANDLED`. If a derived class implements an async method, it must also implement the corresponding finish method.

Available since: 2.30

#### Hierarchy

#### Ancestors

- GObject

#### Instance methods

###### g_tls_interaction_ask_password

Run synchronous interaction to ask the user for a password. In general, `g_tls_interaction_invoke_ask_password()` should be used instead of this function.

since: 2.30

###### g_tls_interaction_ask_password_async

Run asynchronous interaction to ask the user for a password. In general, `g_tls_interaction_invoke_ask_password()` should be used instead of this function.

since: 2.30

###### g_tls_interaction_ask_password_finish

Complete an ask password user interaction request. This should be once the `g_tls_interaction_ask_password_async()` completion callback is called.

since: 2.30

###### g_tls_interaction_invoke_ask_password

Invoke the interaction to ask the user for a password. It invokes this interaction in the main loop, specifically the `GMainContext` returned by `g_main_context_get_thread_default()` when the interaction is created. This is called by called by `GTlsConnection` or `GTlsDatabase` to ask the user for a password.

since: 2.30

###### g_tls_interaction_invoke_request_certificate

Invoke the interaction to ask the user to choose a certificate to use with the connection. It invokes this interaction in the main loop, specifically the `GMainContext` returned by `g_main_context_get_thread_default()` when the interaction is created. This is called by called by `GTlsConnection` when the peer requests a certificate during the handshake.

since: 2.40

###### g_tls_interaction_request_certificate

Run synchronous interaction to ask the user to choose a certificate to use with the connection. In general, `g_tls_interaction_invoke_request_certificate()` should be used instead of this function.

since: 2.40

###### g_tls_interaction_request_certificate_async

Run asynchronous interaction to ask the user for a certificate to use with the connection. In general, `g_tls_interaction_invoke_request_certificate()` should be used instead of this function.

since: 2.40

###### g_tls_interaction_request_certificate_finish

Complete a request certificate user interaction request. This should be once the `g_tls_interaction_request_certificate_async()` completion callback is called.

since: 2.40

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct GioTlsInteractionClass {
      GTlsInteractionResult (* ask_password) (
        GTlsInteraction* interaction,
        GTlsPassword* password,
        GCancellable* cancellable,
        GError** error
      );
      void (* ask_password_async) (
        GTlsInteraction* interaction,
        GTlsPassword* password,
        GCancellable* cancellable,
        GAsyncReadyCallback callback,
        gpointer user_data
      );
      GTlsInteractionResult (* ask_password_finish) (
        GTlsInteraction* interaction,
        GAsyncResult* result,
        GError** error
      );
      GTlsInteractionResult (* request_certificate) (
        GTlsInteraction* interaction,
        GTlsConnection* connection,
        GTlsCertificateRequestFlags flags,
        GCancellable* cancellable,
        GError** error
      );
      void (* request_certificate_async) (
        GTlsInteraction* interaction,
        GTlsConnection* connection,
        GTlsCertificateRequestFlags flags,
        GCancellable* cancellable,
        GAsyncReadyCallback callback,
        gpointer user_data
      );
      GTlsInteractionResult (* request_certificate_finish) (
        GTlsInteraction* interaction,
        GAsyncResult* result,
        GError** error
      );

    }

The class for `GTlsInteraction`. Derived classes implement the various virtual interaction methods to handle TLS interactions.

Derived classes can choose to implement whichever interactions methods they’d like to support by overriding those virtual methods in their class initialization function. If a derived class implements an async method, it must also implement the corresponding finish method.

The synchronous interaction methods should implement to display modal dialogs, and the asynchronous methods to display modeless dialogs.

If the user cancels an interaction, then the result should be `G_TLS_INTERACTION_FAILED` and the error should be set with a domain of `G_IO_ERROR` and code of `G_IO_ERROR_CANCELLED`.

###### Class members

`ask_password: GTlsInteractionResult (* ask_password) ( GTlsInteraction* interaction, GTlsPassword* password, GCancellable* cancellable, GError** error )`

  Ask for a password synchronously. If the implementation returns `G_TLS_INTERACTION_HANDLED`, then the password argument should have been filled in by using `g_tls_password_set_value()` or a similar function.

`ask_password_async: void (* ask_password_async) ( GTlsInteraction* interaction, GTlsPassword* password, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data )`

  Ask for a password asynchronously.

`ask_password_finish: GTlsInteractionResult (* ask_password_finish) ( GTlsInteraction* interaction, GAsyncResult* result, GError** error )`

  Complete operation to ask for a password asynchronously. If the implementation returns `G_TLS_INTERACTION_HANDLED`, then the password argument of the async method should have been filled in by using `g_tls_password_set_value()` or a similar function.

`request_certificate: GTlsInteractionResult (* request_certificate) ( GTlsInteraction* interaction, GTlsConnection* connection, GTlsCertificateRequestFlags flags, GCancellable* cancellable, GError** error )`

  Ask for a certificate synchronously. If the implementation returns `G_TLS_INTERACTION_HANDLED`, then the connection argument should have been filled in by using g_tls_connection_set_certificate().

`request_certificate_async: void (* request_certificate_async) ( GTlsInteraction* interaction, GTlsConnection* connection, GTlsCertificateRequestFlags flags, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data )`

  Ask for a certificate asynchronously.

`request_certificate_finish: GTlsInteractionResult (* request_certificate_finish) ( GTlsInteraction* interaction, GAsyncResult* result, GError** error )`

  Complete operation to ask for a certificate asynchronously. If the implementation returns `G_TLS_INTERACTION_HANDLED`, then the connection argument of the async method should have been filled in by using g_tls_connection_set_certificate().

#### Virtual methods

###### Gio.TlsInteractionClass.ask_password

Run synchronous interaction to ask the user for a password. In general, `g_tls_interaction_invoke_ask_password()` should be used instead of this function.

since: 2.30

###### Gio.TlsInteractionClass.ask_password_async

Run asynchronous interaction to ask the user for a password. In general, `g_tls_interaction_invoke_ask_password()` should be used instead of this function.

since: 2.30

###### Gio.TlsInteractionClass.ask_password_finish

Complete an ask password user interaction request. This should be once the `g_tls_interaction_ask_password_async()` completion callback is called.

since: 2.30

###### Gio.TlsInteractionClass.request_certificate

Run synchronous interaction to ask the user to choose a certificate to use with the connection. In general, `g_tls_interaction_invoke_request_certificate()` should be used instead of this function.

since: 2.40

###### Gio.TlsInteractionClass.request_certificate_async

Run asynchronous interaction to ask the user for a certificate to use with the connection. In general, `g_tls_interaction_invoke_request_certificate()` should be used instead of this function.

since: 2.40

###### Gio.TlsInteractionClass.request_certificate_finish

Complete a request certificate user interaction request. This should be once the `g_tls_interaction_request_certificate_async()` completion callback is called.

since: 2.40