Blame gio/gtlsdatabase.c

Packit ae235b
/* GIO - GLib Input, Output and Streaming Library
Packit ae235b
 *
Packit ae235b
 * Copyright (C) 2010 Collabora, Ltd.
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General
Packit ae235b
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 *
Packit ae235b
 * Author: Stef Walter <stefw@collabora.co.uk>
Packit ae235b
 */
Packit ae235b
Packit ae235b
#include "config.h"
Packit ae235b
Packit ae235b
#include "gtlsdatabase.h"
Packit ae235b
Packit ae235b
#include "gasyncresult.h"
Packit ae235b
#include "gcancellable.h"
Packit ae235b
#include "glibintl.h"
Packit ae235b
#include "gsocketconnectable.h"
Packit ae235b
#include "gtask.h"
Packit ae235b
#include "gtlscertificate.h"
Packit ae235b
#include "gtlsinteraction.h"
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * SECTION:gtlsdatabase
Packit ae235b
 * @short_description: TLS database type
Packit ae235b
 * @include: gio/gio.h
Packit ae235b
 *
Packit ae235b
 * #GTlsDatabase is used to lookup certificates and other information
Packit ae235b
 * from a certificate or key store. It is an abstract base class which
Packit ae235b
 * TLS library specific subtypes override.
Packit ae235b
 *
Packit ae235b
 * Most common client applications will not directly interact with
Packit ae235b
 * #GTlsDatabase. It is used internally by #GTlsConnection.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GTlsDatabase:
Packit ae235b
 *
Packit ae235b
 * Abstract base class for the backend-specific database types.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GTlsDatabaseClass:
Packit ae235b
 * @verify_chain: Virtual method implementing
Packit ae235b
 *  g_tls_database_verify_chain().
Packit ae235b
 * @verify_chain_async: Virtual method implementing
Packit ae235b
 *  g_tls_database_verify_chain_async().
Packit ae235b
 * @verify_chain_finish: Virtual method implementing
Packit ae235b
 *  g_tls_database_verify_chain_finish().
Packit ae235b
 * @create_certificate_handle: Virtual method implementing
Packit ae235b
 *  g_tls_database_create_certificate_handle().
Packit ae235b
 * @lookup_certificate_for_handle: Virtual method implementing
Packit ae235b
 *  g_tls_database_lookup_certificate_for_handle().
Packit ae235b
 * @lookup_certificate_for_handle_async: Virtual method implementing
Packit ae235b
 *  g_tls_database_lookup_certificate_for_handle_async().
Packit ae235b
 * @lookup_certificate_for_handle_finish: Virtual method implementing
Packit ae235b
 *  g_tls_database_lookup_certificate_for_handle_finish().
Packit ae235b
 * @lookup_certificate_issuer: Virtual method implementing
Packit ae235b
 *  g_tls_database_lookup_certificate_issuer().
Packit ae235b
 * @lookup_certificate_issuer_async: Virtual method implementing
Packit ae235b
 *  g_tls_database_lookup_certificate_issuer_async().
Packit ae235b
 * @lookup_certificate_issuer_finish: Virtual method implementing
Packit ae235b
 *  g_tls_database_lookup_certificate_issuer_finish().
Packit ae235b
 * @lookup_certificates_issued_by: Virtual method implementing
Packit ae235b
 *  g_tls_database_lookup_certificates_issued_by().
Packit ae235b
 * @lookup_certificates_issued_by_async: Virtual method implementing
Packit ae235b
 *  g_tls_database_lookup_certificates_issued_by_async().
Packit ae235b
 * @lookup_certificates_issued_by_finish: Virtual method implementing
Packit ae235b
 *  g_tls_database_lookup_certificates_issued_by_finish().
Packit ae235b
 *
Packit ae235b
 * The class for #GTlsDatabase. Derived classes should implement the various
Packit ae235b
 * virtual methods. _async and _finish methods have a default
Packit ae235b
 * implementation that runs the corresponding sync method in a thread.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
Packit ae235b
G_DEFINE_ABSTRACT_TYPE (GTlsDatabase, g_tls_database, G_TYPE_OBJECT)
Packit ae235b
Packit ae235b
enum {
Packit ae235b
  UNLOCK_REQUIRED,
Packit ae235b
Packit ae235b
  LAST_SIGNAL
Packit ae235b
};
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER:
Packit ae235b
 *
Packit ae235b
 * The purpose used to verify the server certificate in a TLS connection. This
Packit ae235b
 * is the most common purpose in use. Used by TLS clients.
Packit ae235b
 */
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT:
Packit ae235b
 *
Packit ae235b
 * The purpose used to verify the client certificate in a TLS connection.
Packit ae235b
 * Used by TLS servers.
Packit ae235b
 */
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_tls_database_init (GTlsDatabase *cert)
Packit ae235b
{
Packit ae235b
Packit ae235b
}
Packit ae235b
Packit ae235b
typedef struct _AsyncVerifyChain {
Packit ae235b
  GTlsCertificate *chain;
Packit ae235b
  gchar *purpose;
Packit ae235b
  GSocketConnectable *identity;
Packit ae235b
  GTlsInteraction *interaction;
Packit ae235b
  GTlsDatabaseVerifyFlags flags;
Packit ae235b
} AsyncVerifyChain;
Packit ae235b
Packit ae235b
static void
Packit ae235b
async_verify_chain_free (gpointer data)
Packit ae235b
{
Packit ae235b
  AsyncVerifyChain *args = data;
Packit ae235b
  g_clear_object (&args->chain);
Packit ae235b
  g_free (args->purpose);
Packit ae235b
  g_clear_object (&args->identity);
Packit ae235b
  g_clear_object (&args->interaction);
Packit ae235b
  g_slice_free (AsyncVerifyChain, args);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
async_verify_chain_thread (GTask         *task,
Packit ae235b
			   gpointer       object,
Packit ae235b
			   gpointer       task_data,
Packit ae235b
			   GCancellable  *cancellable)
Packit ae235b
{
Packit ae235b
  AsyncVerifyChain *args = task_data;
Packit ae235b
  GTlsCertificateFlags verify_result;
Packit ae235b
  GError *error = NULL;
Packit ae235b
Packit ae235b
  verify_result = g_tls_database_verify_chain (G_TLS_DATABASE (object),
Packit ae235b
					       args->chain,
Packit ae235b
					       args->purpose,
Packit ae235b
					       args->identity,
Packit ae235b
					       args->interaction,
Packit ae235b
					       args->flags,
Packit ae235b
					       cancellable,
Packit ae235b
					       &error);
Packit ae235b
  if (error)
Packit ae235b
    g_task_return_error (task, error);
Packit ae235b
  else
Packit ae235b
    g_task_return_int (task, (gssize)verify_result);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_tls_database_real_verify_chain_async (GTlsDatabase           *self,
Packit ae235b
                                        GTlsCertificate        *chain,
Packit ae235b
                                        const gchar            *purpose,
Packit ae235b
                                        GSocketConnectable     *identity,
Packit ae235b
                                        GTlsInteraction        *interaction,
Packit ae235b
                                        GTlsDatabaseVerifyFlags flags,
Packit ae235b
                                        GCancellable           *cancellable,
Packit ae235b
                                        GAsyncReadyCallback     callback,
Packit ae235b
                                        gpointer                user_data)
Packit ae235b
{
Packit ae235b
  GTask *task;
Packit ae235b
  AsyncVerifyChain *args;
Packit ae235b
Packit ae235b
  args = g_slice_new0 (AsyncVerifyChain);
Packit ae235b
  args->chain = g_object_ref (chain);
Packit ae235b
  args->purpose = g_strdup (purpose);
Packit ae235b
  args->identity = identity ? g_object_ref (identity) : NULL;
Packit ae235b
  args->interaction = interaction ? g_object_ref (interaction) : NULL;
Packit ae235b
  args->flags = flags;
Packit ae235b
Packit ae235b
  task = g_task_new (self, cancellable, callback, user_data);
Packit ae235b
  g_task_set_source_tag (task, g_tls_database_real_verify_chain_async);
Packit ae235b
  g_task_set_task_data (task, args, async_verify_chain_free);
Packit ae235b
  g_task_run_in_thread (task, async_verify_chain_thread);
Packit ae235b
  g_object_unref (task);
Packit ae235b
}
Packit ae235b
Packit ae235b
static GTlsCertificateFlags
Packit ae235b
g_tls_database_real_verify_chain_finish (GTlsDatabase          *self,
Packit ae235b
                                         GAsyncResult          *result,
Packit ae235b
                                         GError               **error)
Packit ae235b
{
Packit ae235b
  GTlsCertificateFlags ret;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (g_task_is_valid (result, self), G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
Packit ae235b
  ret = (GTlsCertificateFlags)g_task_propagate_int (G_TASK (result), error);
Packit ae235b
  if (ret == (GTlsCertificateFlags)-1)
Packit ae235b
    return G_TLS_CERTIFICATE_GENERIC_ERROR;
Packit ae235b
  else
Packit ae235b
    return ret;
Packit ae235b
}
Packit ae235b
Packit ae235b
typedef struct {
Packit ae235b
  gchar *handle;
Packit ae235b
  GTlsInteraction *interaction;
Packit ae235b
  GTlsDatabaseLookupFlags flags;
Packit ae235b
} AsyncLookupCertificateForHandle;
Packit ae235b
Packit ae235b
static void
Packit ae235b
async_lookup_certificate_for_handle_free (gpointer data)
Packit ae235b
{
Packit ae235b
  AsyncLookupCertificateForHandle *args = data;
Packit ae235b
Packit ae235b
  g_free (args->handle);
Packit ae235b
  g_clear_object (&args->interaction);
Packit ae235b
  g_slice_free (AsyncLookupCertificateForHandle, args);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
async_lookup_certificate_for_handle_thread (GTask         *task,
Packit ae235b
					    gpointer       object,
Packit ae235b
					    gpointer       task_data,
Packit ae235b
					    GCancellable  *cancellable)
Packit ae235b
{
Packit ae235b
  AsyncLookupCertificateForHandle *args = task_data;
Packit ae235b
  GTlsCertificate *result;
Packit ae235b
  GError *error = NULL;
Packit ae235b
Packit ae235b
  result = g_tls_database_lookup_certificate_for_handle (G_TLS_DATABASE (object),
Packit ae235b
							 args->handle,
Packit ae235b
							 args->interaction,
Packit ae235b
							 args->flags,
Packit ae235b
							 cancellable,
Packit ae235b
							 &error);
Packit ae235b
  if (result)
Packit ae235b
    g_task_return_pointer (task, result, g_object_unref);
Packit ae235b
  else
Packit ae235b
    g_task_return_error (task, error);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_tls_database_real_lookup_certificate_for_handle_async (GTlsDatabase           *self,
Packit ae235b
                                                         const gchar            *handle,
Packit ae235b
                                                         GTlsInteraction        *interaction,
Packit ae235b
                                                         GTlsDatabaseLookupFlags flags,
Packit ae235b
                                                         GCancellable           *cancellable,
Packit ae235b
                                                         GAsyncReadyCallback     callback,
Packit ae235b
                                                         gpointer                user_data)
Packit ae235b
{
Packit ae235b
  GTask *task;
Packit ae235b
  AsyncLookupCertificateForHandle *args;
Packit ae235b
Packit ae235b
  args = g_slice_new0 (AsyncLookupCertificateForHandle);
Packit ae235b
  args->handle = g_strdup (handle);
Packit ae235b
  args->interaction = interaction ? g_object_ref (interaction) : NULL;
Packit ae235b
Packit ae235b
  task = g_task_new (self, cancellable, callback, user_data);
Packit ae235b
  g_task_set_source_tag (task,
Packit ae235b
                         g_tls_database_real_lookup_certificate_for_handle_async);
Packit ae235b
  g_task_set_task_data (task, args, async_lookup_certificate_for_handle_free);
Packit ae235b
  g_task_run_in_thread (task, async_lookup_certificate_for_handle_thread);
Packit ae235b
  g_object_unref (task);
Packit ae235b
}
Packit ae235b
Packit ae235b
static GTlsCertificate*
Packit ae235b
g_tls_database_real_lookup_certificate_for_handle_finish (GTlsDatabase          *self,
Packit ae235b
                                                          GAsyncResult          *result,
Packit ae235b
                                                          GError               **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (g_task_is_valid (result, self), NULL);
Packit ae235b
Packit ae235b
  return g_task_propagate_pointer (G_TASK (result), error);
Packit ae235b
}
Packit ae235b
Packit ae235b
Packit ae235b
typedef struct {
Packit ae235b
  GTlsCertificate *certificate;
Packit ae235b
  GTlsInteraction *interaction;
Packit ae235b
  GTlsDatabaseLookupFlags flags;
Packit ae235b
} AsyncLookupCertificateIssuer;
Packit ae235b
Packit ae235b
static void
Packit ae235b
async_lookup_certificate_issuer_free (gpointer data)
Packit ae235b
{
Packit ae235b
  AsyncLookupCertificateIssuer *args = data;
Packit ae235b
Packit ae235b
  g_clear_object (&args->certificate);
Packit ae235b
  g_clear_object (&args->interaction);
Packit ae235b
  g_slice_free (AsyncLookupCertificateIssuer, args);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
async_lookup_certificate_issuer_thread (GTask         *task,
Packit ae235b
					gpointer       object,
Packit ae235b
					gpointer       task_data,
Packit ae235b
					GCancellable  *cancellable)
Packit ae235b
{
Packit ae235b
  AsyncLookupCertificateIssuer *args = task_data;
Packit ae235b
  GTlsCertificate *issuer;
Packit ae235b
  GError *error = NULL;
Packit ae235b
Packit ae235b
  issuer = g_tls_database_lookup_certificate_issuer (G_TLS_DATABASE (object),
Packit ae235b
						     args->certificate,
Packit ae235b
						     args->interaction,
Packit ae235b
						     args->flags,
Packit ae235b
						     cancellable,
Packit ae235b
						     &error);
Packit ae235b
  if (issuer)
Packit ae235b
    g_task_return_pointer (task, issuer, g_object_unref);
Packit ae235b
  else
Packit ae235b
    g_task_return_error (task, error);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_tls_database_real_lookup_certificate_issuer_async (GTlsDatabase           *self,
Packit ae235b
                                                     GTlsCertificate        *certificate,
Packit ae235b
                                                     GTlsInteraction        *interaction,
Packit ae235b
                                                     GTlsDatabaseLookupFlags flags,
Packit ae235b
                                                     GCancellable           *cancellable,
Packit ae235b
                                                     GAsyncReadyCallback     callback,
Packit ae235b
                                                     gpointer                user_data)
Packit ae235b
{
Packit ae235b
  GTask *task;
Packit ae235b
  AsyncLookupCertificateIssuer *args;
Packit ae235b
Packit ae235b
  args = g_slice_new0 (AsyncLookupCertificateIssuer);
Packit ae235b
  args->certificate = g_object_ref (certificate);
Packit ae235b
  args->flags = flags;
Packit ae235b
  args->interaction = interaction ? g_object_ref (interaction) : NULL;
Packit ae235b
Packit ae235b
  task = g_task_new (self, cancellable, callback, user_data);
Packit ae235b
  g_task_set_source_tag (task,
Packit ae235b
                         g_tls_database_real_lookup_certificate_issuer_async);
Packit ae235b
  g_task_set_task_data (task, args, async_lookup_certificate_issuer_free);
Packit ae235b
  g_task_run_in_thread (task, async_lookup_certificate_issuer_thread);
Packit ae235b
  g_object_unref (task);
Packit ae235b
}
Packit ae235b
Packit ae235b
static GTlsCertificate *
Packit ae235b
g_tls_database_real_lookup_certificate_issuer_finish (GTlsDatabase          *self,
Packit ae235b
                                                      GAsyncResult          *result,
Packit ae235b
                                                      GError               **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (g_task_is_valid (result, self), NULL);
Packit ae235b
Packit ae235b
  return g_task_propagate_pointer (G_TASK (result), error);
Packit ae235b
}
Packit ae235b
Packit ae235b
typedef struct {
Packit ae235b
  GByteArray *issuer;
Packit ae235b
  GTlsInteraction *interaction;
Packit ae235b
  GTlsDatabaseLookupFlags flags;
Packit ae235b
} AsyncLookupCertificatesIssuedBy;
Packit ae235b
Packit ae235b
static void
Packit ae235b
async_lookup_certificates_issued_by_free (gpointer data)
Packit ae235b
{
Packit ae235b
  AsyncLookupCertificatesIssuedBy *args = data;
Packit ae235b
Packit ae235b
  g_byte_array_unref (args->issuer);
Packit ae235b
  g_clear_object (&args->interaction);
Packit ae235b
  g_slice_free (AsyncLookupCertificatesIssuedBy, args);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
async_lookup_certificates_free_certificates (gpointer data)
Packit ae235b
{
Packit ae235b
  GList *list = data;
Packit ae235b
Packit ae235b
  g_list_free_full (list, g_object_unref);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
async_lookup_certificates_issued_by_thread (GTask         *task,
Packit ae235b
					    gpointer       object,
Packit ae235b
					    gpointer       task_data,
Packit ae235b
                                            GCancellable  *cancellable)
Packit ae235b
{
Packit ae235b
  AsyncLookupCertificatesIssuedBy *args = task_data;
Packit ae235b
  GList *results;
Packit ae235b
  GError *error = NULL;
Packit ae235b
Packit ae235b
  results = g_tls_database_lookup_certificates_issued_by (G_TLS_DATABASE (object),
Packit ae235b
							  args->issuer,
Packit ae235b
							  args->interaction,
Packit ae235b
							  args->flags,
Packit ae235b
							  cancellable,
Packit ae235b
							  &error);
Packit ae235b
  if (results)
Packit ae235b
    g_task_return_pointer (task, results, async_lookup_certificates_free_certificates);
Packit ae235b
  else
Packit ae235b
    g_task_return_error (task, error);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_tls_database_real_lookup_certificates_issued_by_async (GTlsDatabase           *self,
Packit ae235b
                                                         GByteArray             *issuer,
Packit ae235b
                                                         GTlsInteraction        *interaction,
Packit ae235b
                                                         GTlsDatabaseLookupFlags flags,
Packit ae235b
                                                         GCancellable           *cancellable,
Packit ae235b
                                                         GAsyncReadyCallback     callback,
Packit ae235b
                                                         gpointer                user_data)
Packit ae235b
{
Packit ae235b
  GTask *task;
Packit ae235b
  AsyncLookupCertificatesIssuedBy *args;
Packit ae235b
Packit ae235b
  args = g_slice_new0 (AsyncLookupCertificatesIssuedBy);
Packit ae235b
  args->issuer = g_byte_array_ref (issuer);
Packit ae235b
  args->flags = flags;
Packit ae235b
  args->interaction = interaction ? g_object_ref (interaction) : NULL;
Packit ae235b
Packit ae235b
  task = g_task_new (self, cancellable, callback, user_data);
Packit ae235b
  g_task_set_source_tag (task,
Packit ae235b
                         g_tls_database_real_lookup_certificates_issued_by_async);
Packit ae235b
  g_task_set_task_data (task, args, async_lookup_certificates_issued_by_free);
Packit ae235b
  g_task_run_in_thread (task, async_lookup_certificates_issued_by_thread);
Packit ae235b
  g_object_unref (task);
Packit ae235b
}
Packit ae235b
Packit ae235b
static GList *
Packit ae235b
g_tls_database_real_lookup_certificates_issued_by_finish (GTlsDatabase          *self,
Packit ae235b
                                                          GAsyncResult          *result,
Packit ae235b
                                                          GError               **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (g_task_is_valid (result, self), NULL);
Packit ae235b
Packit ae235b
  return g_task_propagate_pointer (G_TASK (result), error);
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_tls_database_class_init (GTlsDatabaseClass *klass)
Packit ae235b
{
Packit ae235b
  klass->verify_chain_async = g_tls_database_real_verify_chain_async;
Packit ae235b
  klass->verify_chain_finish = g_tls_database_real_verify_chain_finish;
Packit ae235b
  klass->lookup_certificate_for_handle_async = g_tls_database_real_lookup_certificate_for_handle_async;
Packit ae235b
  klass->lookup_certificate_for_handle_finish = g_tls_database_real_lookup_certificate_for_handle_finish;
Packit ae235b
  klass->lookup_certificate_issuer_async = g_tls_database_real_lookup_certificate_issuer_async;
Packit ae235b
  klass->lookup_certificate_issuer_finish = g_tls_database_real_lookup_certificate_issuer_finish;
Packit ae235b
  klass->lookup_certificates_issued_by_async = g_tls_database_real_lookup_certificates_issued_by_async;
Packit ae235b
  klass->lookup_certificates_issued_by_finish = g_tls_database_real_lookup_certificates_issued_by_finish;
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_verify_chain:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @chain: a #GTlsCertificate chain
Packit ae235b
 * @purpose: the purpose that this certificate chain will be used for.
Packit ae235b
 * @identity: (nullable): the expected peer identity
Packit ae235b
 * @interaction: (nullable): used to interact with the user if necessary
Packit ae235b
 * @flags: additional verify flags
Packit ae235b
 * @cancellable: (nullable): a #GCancellable, or %NULL
Packit ae235b
 * @error: (nullable): a #GError, or %NULL
Packit ae235b
 *
Packit ae235b
 * Determines the validity of a certificate chain after looking up and
Packit ae235b
 * adding any missing certificates to the chain.
Packit ae235b
 *
Packit ae235b
 * @chain is a chain of #GTlsCertificate objects each pointing to the next
Packit ae235b
 * certificate in the chain by its #GTlsCertificate:issuer property. The chain may initially
Packit ae235b
 * consist of one or more certificates. After the verification process is
Packit ae235b
 * complete, @chain may be modified by adding missing certificates, or removing
Packit ae235b
 * extra certificates. If a certificate anchor was found, then it is added to
Packit ae235b
 * the @chain.
Packit ae235b
 *
Packit ae235b
 * @purpose describes the purpose (or usage) for which the certificate
Packit ae235b
 * is being used. Typically @purpose will be set to #G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER
Packit ae235b
 * which means that the certificate is being used to authenticate a server
Packit ae235b
 * (and we are acting as the client).
Packit ae235b
 *
Packit ae235b
 * The @identity is used to check for pinned certificates (trust exceptions)
Packit ae235b
 * in the database. These will override the normal verification process on a
Packit ae235b
 * host by host basis.
Packit ae235b
 *
Packit ae235b
 * Currently there are no @flags, and %G_TLS_DATABASE_VERIFY_NONE should be
Packit ae235b
 * used.
Packit ae235b
 *
Packit ae235b
 * If @chain is found to be valid, then the return value will be 0. If
Packit ae235b
 * @chain is found to be invalid, then the return value will indicate
Packit ae235b
 * the problems found. If the function is unable to determine whether
Packit ae235b
 * @chain is valid or not (eg, because @cancellable is triggered
Packit ae235b
 * before it completes) then the return value will be
Packit ae235b
 * %G_TLS_CERTIFICATE_GENERIC_ERROR and @error will be set
Packit ae235b
 * accordingly. @error is not set when @chain is successfully analyzed
Packit ae235b
 * but found to be invalid.
Packit ae235b
 *
Packit ae235b
 * This function can block, use g_tls_database_verify_chain_async() to perform
Packit ae235b
 * the verification operation asynchronously.
Packit ae235b
 *
Packit ae235b
 * Returns: the appropriate #GTlsCertificateFlags which represents the
Packit ae235b
 * result of verification.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
GTlsCertificateFlags
Packit ae235b
g_tls_database_verify_chain (GTlsDatabase           *self,
Packit ae235b
                             GTlsCertificate        *chain,
Packit ae235b
                             const gchar            *purpose,
Packit ae235b
                             GSocketConnectable     *identity,
Packit ae235b
                             GTlsInteraction        *interaction,
Packit ae235b
                             GTlsDatabaseVerifyFlags flags,
Packit ae235b
                             GCancellable           *cancellable,
Packit ae235b
                             GError                **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self), G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self),
Packit ae235b
                        G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_CERTIFICATE (chain),
Packit ae235b
                        G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  g_return_val_if_fail (purpose, G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  g_return_val_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction),
Packit ae235b
                        G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  g_return_val_if_fail (identity == NULL || G_IS_SOCKET_CONNECTABLE (identity),
Packit ae235b
                        G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  g_return_val_if_fail (error == NULL || *error == NULL, G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
Packit ae235b
  g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->verify_chain,
Packit ae235b
                        G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
Packit ae235b
  return G_TLS_DATABASE_GET_CLASS (self)->verify_chain (self,
Packit ae235b
                                                        chain,
Packit ae235b
                                                        purpose,
Packit ae235b
                                                        identity,
Packit ae235b
                                                        interaction,
Packit ae235b
                                                        flags,
Packit ae235b
                                                        cancellable,
Packit ae235b
                                                        error);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_verify_chain_async:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @chain: a #GTlsCertificate chain
Packit ae235b
 * @purpose: the purpose that this certificate chain will be used for.
Packit ae235b
 * @identity: (nullable): the expected peer identity
Packit ae235b
 * @interaction: (nullable): used to interact with the user if necessary
Packit ae235b
 * @flags: additional verify flags
Packit ae235b
 * @cancellable: (nullable): a #GCancellable, or %NULL
Packit ae235b
 * @callback: callback to call when the operation completes
Packit ae235b
 * @user_data: the data to pass to the callback function
Packit ae235b
 *
Packit ae235b
 * Asynchronously determines the validity of a certificate chain after
Packit ae235b
 * looking up and adding any missing certificates to the chain. See
Packit ae235b
 * g_tls_database_verify_chain() for more information.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
g_tls_database_verify_chain_async (GTlsDatabase           *self,
Packit ae235b
                                   GTlsCertificate        *chain,
Packit ae235b
                                   const gchar            *purpose,
Packit ae235b
                                   GSocketConnectable     *identity,
Packit ae235b
                                   GTlsInteraction        *interaction,
Packit ae235b
                                   GTlsDatabaseVerifyFlags flags,
Packit ae235b
                                   GCancellable           *cancellable,
Packit ae235b
                                   GAsyncReadyCallback     callback,
Packit ae235b
                                   gpointer                user_data)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (G_IS_TLS_DATABASE (self));
Packit ae235b
  g_return_if_fail (G_IS_TLS_CERTIFICATE (chain));
Packit ae235b
  g_return_if_fail (purpose != NULL);
Packit ae235b
  g_return_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction));
Packit ae235b
  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
Packit ae235b
  g_return_if_fail (identity == NULL || G_IS_SOCKET_CONNECTABLE (identity));
Packit ae235b
  g_return_if_fail (callback != NULL);
Packit ae235b
Packit ae235b
  g_return_if_fail (G_TLS_DATABASE_GET_CLASS (self)->verify_chain_async);
Packit ae235b
  G_TLS_DATABASE_GET_CLASS (self)->verify_chain_async (self,
Packit ae235b
                                                       chain,
Packit ae235b
                                                       purpose,
Packit ae235b
                                                       identity,
Packit ae235b
                                                       interaction,
Packit ae235b
                                                       flags,
Packit ae235b
                                                       cancellable,
Packit ae235b
                                                       callback,
Packit ae235b
                                                       user_data);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_verify_chain_finish:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @result: a #GAsyncResult.
Packit ae235b
 * @error: a #GError pointer, or %NULL
Packit ae235b
 *
Packit ae235b
 * Finish an asynchronous verify chain operation. See
Packit ae235b
 * g_tls_database_verify_chain() for more information.
Packit ae235b
 *
Packit ae235b
 * If @chain is found to be valid, then the return value will be 0. If
Packit ae235b
 * @chain is found to be invalid, then the return value will indicate
Packit ae235b
 * the problems found. If the function is unable to determine whether
Packit ae235b
 * @chain is valid or not (eg, because @cancellable is triggered
Packit ae235b
 * before it completes) then the return value will be
Packit ae235b
 * %G_TLS_CERTIFICATE_GENERIC_ERROR and @error will be set
Packit ae235b
 * accordingly. @error is not set when @chain is successfully analyzed
Packit ae235b
 * but found to be invalid.
Packit ae235b
 *
Packit ae235b
 * Returns: the appropriate #GTlsCertificateFlags which represents the
Packit ae235b
 * result of verification.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
GTlsCertificateFlags
Packit ae235b
g_tls_database_verify_chain_finish (GTlsDatabase          *self,
Packit ae235b
                                    GAsyncResult          *result,
Packit ae235b
                                    GError               **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self), G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  g_return_val_if_fail (G_IS_ASYNC_RESULT (result), G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  g_return_val_if_fail (error == NULL || *error == NULL, G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->verify_chain_finish,
Packit ae235b
                        G_TLS_CERTIFICATE_GENERIC_ERROR);
Packit ae235b
  return G_TLS_DATABASE_GET_CLASS (self)->verify_chain_finish (self,
Packit ae235b
                                                               result,
Packit ae235b
                                                               error);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_create_certificate_handle:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @certificate: certificate for which to create a handle.
Packit ae235b
 *
Packit ae235b
 * Create a handle string for the certificate. The database will only be able
Packit ae235b
 * to create a handle for certificates that originate from the database. In
Packit ae235b
 * cases where the database cannot create a handle for a certificate, %NULL
Packit ae235b
 * will be returned.
Packit ae235b
 *
Packit ae235b
 * This handle should be stable across various instances of the application,
Packit ae235b
 * and between applications. If a certificate is modified in the database,
Packit ae235b
 * then it is not guaranteed that this handle will continue to point to it.
Packit ae235b
 *
Packit ae235b
 * Returns: (nullable): a newly allocated string containing the
Packit ae235b
 * handle.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
gchar*
Packit ae235b
g_tls_database_create_certificate_handle (GTlsDatabase            *self,
Packit ae235b
                                          GTlsCertificate         *certificate)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL);
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_CERTIFICATE (certificate), NULL);
Packit ae235b
  g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->create_certificate_handle, NULL);
Packit ae235b
  return G_TLS_DATABASE_GET_CLASS (self)->create_certificate_handle (self,
Packit ae235b
                                                                     certificate);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_lookup_certificate_for_handle:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @handle: a certificate handle
Packit ae235b
 * @interaction: (nullable): used to interact with the user if necessary
Packit ae235b
 * @flags: Flags which affect the lookup.
Packit ae235b
 * @cancellable: (nullable): a #GCancellable, or %NULL
Packit ae235b
 * @error: (nullable): a #GError, or %NULL
Packit ae235b
 *
Packit ae235b
 * Lookup a certificate by its handle.
Packit ae235b
 *
Packit ae235b
 * The handle should have been created by calling
Packit ae235b
 * g_tls_database_create_certificate_handle() on a #GTlsDatabase object of
Packit ae235b
 * the same TLS backend. The handle is designed to remain valid across
Packit ae235b
 * instantiations of the database.
Packit ae235b
 *
Packit ae235b
 * If the handle is no longer valid, or does not point to a certificate in
Packit ae235b
 * this database, then %NULL will be returned.
Packit ae235b
 *
Packit ae235b
 * This function can block, use g_tls_database_lookup_certificate_for_handle_async() to perform
Packit ae235b
 * the lookup operation asynchronously.
Packit ae235b
 *
Packit ae235b
 * Returns: (transfer full) (nullable): a newly allocated
Packit ae235b
 * #GTlsCertificate, or %NULL. Use g_object_unref() to release the certificate.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
GTlsCertificate*
Packit ae235b
g_tls_database_lookup_certificate_for_handle (GTlsDatabase            *self,
Packit ae235b
                                              const gchar             *handle,
Packit ae235b
                                              GTlsInteraction         *interaction,
Packit ae235b
                                              GTlsDatabaseLookupFlags  flags,
Packit ae235b
                                              GCancellable            *cancellable,
Packit ae235b
                                              GError                 **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL);
Packit ae235b
  g_return_val_if_fail (handle != NULL, NULL);
Packit ae235b
  g_return_val_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction), NULL);
Packit ae235b
  g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
Packit ae235b
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
Packit ae235b
  g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle, NULL);
Packit ae235b
  return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle (self,
Packit ae235b
                                                                         handle,
Packit ae235b
                                                                         interaction,
Packit ae235b
                                                                         flags,
Packit ae235b
                                                                         cancellable,
Packit ae235b
                                                                         error);
Packit ae235b
}
Packit ae235b
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_lookup_certificate_for_handle_async:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @handle: a certificate handle
Packit ae235b
 * @interaction: (nullable): used to interact with the user if necessary
Packit ae235b
 * @flags: Flags which affect the lookup.
Packit ae235b
 * @cancellable: (nullable): a #GCancellable, or %NULL
Packit ae235b
 * @callback: callback to call when the operation completes
Packit ae235b
 * @user_data: the data to pass to the callback function
Packit ae235b
 *
Packit ae235b
 * Asynchronously lookup a certificate by its handle in the database. See
Packit ae235b
 * g_tls_database_lookup_certificate_for_handle() for more information.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
g_tls_database_lookup_certificate_for_handle_async (GTlsDatabase            *self,
Packit ae235b
                                                    const gchar             *handle,
Packit ae235b
                                                    GTlsInteraction         *interaction,
Packit ae235b
                                                    GTlsDatabaseLookupFlags  flags,
Packit ae235b
                                                    GCancellable            *cancellable,
Packit ae235b
                                                    GAsyncReadyCallback      callback,
Packit ae235b
                                                    gpointer                 user_data)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (G_IS_TLS_DATABASE (self));
Packit ae235b
  g_return_if_fail (handle != NULL);
Packit ae235b
  g_return_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction));
Packit ae235b
  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
Packit ae235b
  g_return_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle_async);
Packit ae235b
  G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle_async (self,
Packit ae235b
                                                                               handle,
Packit ae235b
                                                                               interaction,
Packit ae235b
                                                                               flags,
Packit ae235b
                                                                               cancellable,
Packit ae235b
                                                                               callback,
Packit ae235b
                                                                               user_data);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_lookup_certificate_for_handle_finish:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @result: a #GAsyncResult.
Packit ae235b
 * @error: a #GError pointer, or %NULL
Packit ae235b
 *
Packit ae235b
 * Finish an asynchronous lookup of a certificate by its handle. See
Packit ae235b
 * g_tls_database_lookup_certificate_by_handle() for more information.
Packit ae235b
 *
Packit ae235b
 * If the handle is no longer valid, or does not point to a certificate in
Packit ae235b
 * this database, then %NULL will be returned.
Packit ae235b
 *
Packit ae235b
 * Returns: (transfer full): a newly allocated #GTlsCertificate object.
Packit ae235b
 * Use g_object_unref() to release the certificate.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
GTlsCertificate*
Packit ae235b
g_tls_database_lookup_certificate_for_handle_finish (GTlsDatabase            *self,
Packit ae235b
                                                     GAsyncResult            *result,
Packit ae235b
                                                     GError                 **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL);
Packit ae235b
  g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
Packit ae235b
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
Packit ae235b
  g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle_finish, NULL);
Packit ae235b
  return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle_finish (self,
Packit ae235b
                                                                                result,
Packit ae235b
                                                                                error);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_lookup_certificate_issuer:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @certificate: a #GTlsCertificate
Packit ae235b
 * @interaction: (nullable): used to interact with the user if necessary
Packit ae235b
 * @flags: flags which affect the lookup operation
Packit ae235b
 * @cancellable: (nullable): a #GCancellable, or %NULL
Packit ae235b
 * @error: (nullable): a #GError, or %NULL
Packit ae235b
 *
Packit ae235b
 * Lookup the issuer of @certificate in the database.
Packit ae235b
 *
Packit ae235b
 * The %issuer property
Packit ae235b
 * of @certificate is not modified, and the two certificates are not hooked
Packit ae235b
 * into a chain.
Packit ae235b
 *
Packit ae235b
 * This function can block, use g_tls_database_lookup_certificate_issuer_async() to perform
Packit ae235b
 * the lookup operation asynchronously.
Packit ae235b
 *
Packit ae235b
 * Returns: (transfer full): a newly allocated issuer #GTlsCertificate,
Packit ae235b
 * or %NULL. Use g_object_unref() to release the certificate.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
GTlsCertificate*
Packit ae235b
g_tls_database_lookup_certificate_issuer (GTlsDatabase           *self,
Packit ae235b
                                          GTlsCertificate        *certificate,
Packit ae235b
                                          GTlsInteraction        *interaction,
Packit ae235b
                                          GTlsDatabaseLookupFlags flags,
Packit ae235b
                                          GCancellable           *cancellable,
Packit ae235b
                                          GError                **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL);
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_CERTIFICATE (certificate), NULL);
Packit ae235b
  g_return_val_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction), NULL);
Packit ae235b
  g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
Packit ae235b
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
Packit ae235b
  g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer, NULL);
Packit ae235b
  return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer (self,
Packit ae235b
                                                                     certificate,
Packit ae235b
                                                                     interaction,
Packit ae235b
                                                                     flags,
Packit ae235b
                                                                     cancellable,
Packit ae235b
                                                                     error);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_lookup_certificate_issuer_async:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @certificate: a #GTlsCertificate
Packit ae235b
 * @interaction: (nullable): used to interact with the user if necessary
Packit ae235b
 * @flags: flags which affect the lookup operation
Packit ae235b
 * @cancellable: (nullable): a #GCancellable, or %NULL
Packit ae235b
 * @callback: callback to call when the operation completes
Packit ae235b
 * @user_data: the data to pass to the callback function
Packit ae235b
 *
Packit ae235b
 * Asynchronously lookup the issuer of @certificate in the database. See
Packit ae235b
 * g_tls_database_lookup_certificate_issuer() for more information.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
g_tls_database_lookup_certificate_issuer_async (GTlsDatabase           *self,
Packit ae235b
                                                GTlsCertificate        *certificate,
Packit ae235b
                                                GTlsInteraction        *interaction,
Packit ae235b
                                                GTlsDatabaseLookupFlags flags,
Packit ae235b
                                                GCancellable           *cancellable,
Packit ae235b
                                                GAsyncReadyCallback     callback,
Packit ae235b
                                                gpointer                user_data)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (G_IS_TLS_DATABASE (self));
Packit ae235b
  g_return_if_fail (G_IS_TLS_CERTIFICATE (certificate));
Packit ae235b
  g_return_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction));
Packit ae235b
  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
Packit ae235b
  g_return_if_fail (callback != NULL);
Packit ae235b
  g_return_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer_async);
Packit ae235b
  G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer_async (self,
Packit ae235b
                                                        certificate,
Packit ae235b
                                                        interaction,
Packit ae235b
                                                        flags,
Packit ae235b
                                                        cancellable,
Packit ae235b
                                                        callback,
Packit ae235b
                                                        user_data);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_lookup_certificate_issuer_finish:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @result: a #GAsyncResult.
Packit ae235b
 * @error: a #GError pointer, or %NULL
Packit ae235b
 *
Packit ae235b
 * Finish an asynchronous lookup issuer operation. See
Packit ae235b
 * g_tls_database_lookup_certificate_issuer() for more information.
Packit ae235b
 *
Packit ae235b
 * Returns: (transfer full): a newly allocated issuer #GTlsCertificate,
Packit ae235b
 * or %NULL. Use g_object_unref() to release the certificate.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
GTlsCertificate*
Packit ae235b
g_tls_database_lookup_certificate_issuer_finish (GTlsDatabase          *self,
Packit ae235b
                                                 GAsyncResult          *result,
Packit ae235b
                                                 GError               **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL);
Packit ae235b
  g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
Packit ae235b
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
Packit ae235b
  g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer_finish, NULL);
Packit ae235b
  return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer_finish (self,
Packit ae235b
                                                                result,
Packit ae235b
                                                                error);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_lookup_certificates_issued_by:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @issuer_raw_dn: a #GByteArray which holds the DER encoded issuer DN.
Packit ae235b
 * @interaction: (nullable): used to interact with the user if necessary
Packit ae235b
 * @flags: Flags which affect the lookup operation.
Packit ae235b
 * @cancellable: (nullable): a #GCancellable, or %NULL
Packit ae235b
 * @error: (nullable): a #GError, or %NULL
Packit ae235b
 *
Packit ae235b
 * Lookup certificates issued by this issuer in the database.
Packit ae235b
 *
Packit ae235b
 * This function can block, use g_tls_database_lookup_certificates_issued_by_async() to perform
Packit ae235b
 * the lookup operation asynchronously.
Packit ae235b
 *
Packit ae235b
 * Returns: (transfer full) (element-type GTlsCertificate): a newly allocated list of #GTlsCertificate
Packit ae235b
 * objects. Use g_object_unref() on each certificate, and g_list_free() on the release the list.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
GList*
Packit ae235b
g_tls_database_lookup_certificates_issued_by (GTlsDatabase           *self,
Packit ae235b
                                              GByteArray             *issuer_raw_dn,
Packit ae235b
                                              GTlsInteraction        *interaction,
Packit ae235b
                                              GTlsDatabaseLookupFlags flags,
Packit ae235b
                                              GCancellable           *cancellable,
Packit ae235b
                                              GError                **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL);
Packit ae235b
  g_return_val_if_fail (issuer_raw_dn, NULL);
Packit ae235b
  g_return_val_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction), NULL);
Packit ae235b
  g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
Packit ae235b
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
Packit ae235b
  g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by, NULL);
Packit ae235b
  return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by (self,
Packit ae235b
                                                                         issuer_raw_dn,
Packit ae235b
                                                                         interaction,
Packit ae235b
                                                                         flags,
Packit ae235b
                                                                         cancellable,
Packit ae235b
                                                                         error);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_lookup_certificates_issued_by_async:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @issuer_raw_dn: a #GByteArray which holds the DER encoded issuer DN.
Packit ae235b
 * @interaction: (nullable): used to interact with the user if necessary
Packit ae235b
 * @flags: Flags which affect the lookup operation.
Packit ae235b
 * @cancellable: (nullable): a #GCancellable, or %NULL
Packit ae235b
 * @callback: callback to call when the operation completes
Packit ae235b
 * @user_data: the data to pass to the callback function
Packit ae235b
 *
Packit ae235b
 * Asynchronously lookup certificates issued by this issuer in the database. See
Packit ae235b
 * g_tls_database_lookup_certificates_issued_by() for more information.
Packit ae235b
 *
Packit ae235b
 * The database may choose to hold a reference to the issuer byte array for the duration
Packit ae235b
 * of of this asynchronous operation. The byte array should not be modified during
Packit ae235b
 * this time.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
void
Packit ae235b
g_tls_database_lookup_certificates_issued_by_async (GTlsDatabase           *self,
Packit ae235b
                                                    GByteArray             *issuer_raw_dn,
Packit ae235b
                                                    GTlsInteraction        *interaction,
Packit ae235b
                                                    GTlsDatabaseLookupFlags flags,
Packit ae235b
                                                    GCancellable           *cancellable,
Packit ae235b
                                                    GAsyncReadyCallback     callback,
Packit ae235b
                                                    gpointer                user_data)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (G_IS_TLS_DATABASE (self));
Packit ae235b
  g_return_if_fail (issuer_raw_dn != NULL);
Packit ae235b
  g_return_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction));
Packit ae235b
  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
Packit ae235b
  g_return_if_fail (callback != NULL);
Packit ae235b
  g_return_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by_async);
Packit ae235b
  G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by_async (self,
Packit ae235b
                                                                        issuer_raw_dn,
Packit ae235b
                                                                        interaction,
Packit ae235b
                                                                        flags,
Packit ae235b
                                                                        cancellable,
Packit ae235b
                                                                        callback,
Packit ae235b
                                                                        user_data);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_tls_database_lookup_certificates_issued_by_finish:
Packit ae235b
 * @self: a #GTlsDatabase
Packit ae235b
 * @result: a #GAsyncResult.
Packit ae235b
 * @error: a #GError pointer, or %NULL
Packit ae235b
 *
Packit ae235b
 * Finish an asynchronous lookup of certificates. See
Packit ae235b
 * g_tls_database_lookup_certificates_issued_by() for more information.
Packit ae235b
 *
Packit ae235b
 * Returns: (transfer full) (element-type GTlsCertificate): a newly allocated list of #GTlsCertificate
Packit ae235b
 * objects. Use g_object_unref() on each certificate, and g_list_free() on the release the list.
Packit ae235b
 *
Packit ae235b
 * Since: 2.30
Packit ae235b
 */
Packit ae235b
GList*
Packit ae235b
g_tls_database_lookup_certificates_issued_by_finish (GTlsDatabase          *self,
Packit ae235b
                                                     GAsyncResult          *result,
Packit ae235b
                                                     GError               **error)
Packit ae235b
{
Packit ae235b
  g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL);
Packit ae235b
  g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
Packit ae235b
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
Packit ae235b
  g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by_finish, NULL);
Packit ae235b
  return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by_finish (self,
Packit ae235b
                                                                                result,
Packit ae235b
                                                                                error);
Packit ae235b
}