| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | /* GIO - GLib Input, Output and Streaming Library
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2010 Collabora, Ltd. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-05-18 09:12:45 +01:00
										 |  |  |  * SPDX-License-Identifier: LGPL-2.1-or-later | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							| 
									
										
										
										
											2017-05-27 18:21:30 +02:00
										 |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This library is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Lesser General | 
					
						
							| 
									
										
										
										
											2014-01-23 12:58:29 +01:00
										 |  |  |  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Author: Stef Walter <stefw@collabora.co.uk> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "config.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "gtlsdatabase.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "gasyncresult.h"
 | 
					
						
							|  |  |  | #include "gcancellable.h"
 | 
					
						
							|  |  |  | #include "glibintl.h"
 | 
					
						
							|  |  |  | #include "gsocketconnectable.h"
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  | #include "gtask.h"
 | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | #include "gtlscertificate.h"
 | 
					
						
							|  |  |  | #include "gtlsinteraction.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2023-11-02 16:26:02 +00:00
										 |  |  |  * GTlsDatabase: | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2023-11-02 16:26:02 +00:00
										 |  |  |  * `GTlsDatabase` is used to look up certificates and other information | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * from a certificate or key store. It is an abstract base class which | 
					
						
							|  |  |  |  * TLS library specific subtypes override. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2023-11-02 16:26:02 +00:00
										 |  |  |  * A `GTlsDatabase` may be accessed from multiple threads by the TLS backend. | 
					
						
							| 
									
										
										
										
											2018-08-27 21:36:11 +10:00
										 |  |  |  * All implementations are required to be fully thread-safe. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * Most common client applications will not directly interact with | 
					
						
							| 
									
										
										
										
											2023-11-02 16:26:02 +00:00
										 |  |  |  * `GTlsDatabase`. It is used internally by [class@Gio.TlsConnection]. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-08 11:09:39 -04:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * GTlsDatabaseClass: | 
					
						
							|  |  |  |  * @verify_chain: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_verify_chain(). | 
					
						
							|  |  |  |  * @verify_chain_async: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_verify_chain_async(). | 
					
						
							|  |  |  |  * @verify_chain_finish: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_verify_chain_finish(). | 
					
						
							|  |  |  |  * @create_certificate_handle: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_create_certificate_handle(). | 
					
						
							|  |  |  |  * @lookup_certificate_for_handle: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_lookup_certificate_for_handle(). | 
					
						
							|  |  |  |  * @lookup_certificate_for_handle_async: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_lookup_certificate_for_handle_async(). | 
					
						
							|  |  |  |  * @lookup_certificate_for_handle_finish: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_lookup_certificate_for_handle_finish(). | 
					
						
							|  |  |  |  * @lookup_certificate_issuer: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_lookup_certificate_issuer(). | 
					
						
							|  |  |  |  * @lookup_certificate_issuer_async: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_lookup_certificate_issuer_async(). | 
					
						
							|  |  |  |  * @lookup_certificate_issuer_finish: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_lookup_certificate_issuer_finish(). | 
					
						
							|  |  |  |  * @lookup_certificates_issued_by: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_lookup_certificates_issued_by(). | 
					
						
							|  |  |  |  * @lookup_certificates_issued_by_async: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_lookup_certificates_issued_by_async(). | 
					
						
							|  |  |  |  * @lookup_certificates_issued_by_finish: Virtual method implementing | 
					
						
							|  |  |  |  *  g_tls_database_lookup_certificates_issued_by_finish(). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The class for #GTlsDatabase. Derived classes should implement the various | 
					
						
							|  |  |  |  * virtual methods. _async and _finish methods have a default | 
					
						
							|  |  |  |  * implementation that runs the corresponding sync method in a thread. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-17 11:54:02 +01:00
										 |  |  | G_DEFINE_ABSTRACT_TYPE (GTlsDatabase, g_tls_database, G_TYPE_OBJECT) | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | enum { | 
					
						
							|  |  |  |   UNLOCK_REQUIRED, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   LAST_SIGNAL | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The purpose used to verify the server certificate in a TLS connection. This | 
					
						
							|  |  |  |  * is the most common purpose in use. Used by TLS clients. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The purpose used to verify the client certificate in a TLS connection. | 
					
						
							|  |  |  |  * Used by TLS servers. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_tls_database_init (GTlsDatabase *cert) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct _AsyncVerifyChain { | 
					
						
							|  |  |  |   GTlsCertificate *chain; | 
					
						
							|  |  |  |   gchar *purpose; | 
					
						
							|  |  |  |   GSocketConnectable *identity; | 
					
						
							|  |  |  |   GTlsInteraction *interaction; | 
					
						
							|  |  |  |   GTlsDatabaseVerifyFlags flags; | 
					
						
							|  |  |  | } AsyncVerifyChain; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | async_verify_chain_free (gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   AsyncVerifyChain *args = data; | 
					
						
							|  |  |  |   g_clear_object (&args->chain); | 
					
						
							|  |  |  |   g_free (args->purpose); | 
					
						
							|  |  |  |   g_clear_object (&args->identity); | 
					
						
							|  |  |  |   g_clear_object (&args->interaction); | 
					
						
							|  |  |  |   g_slice_free (AsyncVerifyChain, args); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  | async_verify_chain_thread (GTask         *task, | 
					
						
							|  |  |  | 			   gpointer       object, | 
					
						
							|  |  |  | 			   gpointer       task_data, | 
					
						
							|  |  |  | 			   GCancellable  *cancellable) | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   AsyncVerifyChain *args = task_data; | 
					
						
							|  |  |  |   GTlsCertificateFlags verify_result; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |   GError *error = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   verify_result = g_tls_database_verify_chain (G_TLS_DATABASE (object), | 
					
						
							|  |  |  | 					       args->chain, | 
					
						
							|  |  |  | 					       args->purpose, | 
					
						
							|  |  |  | 					       args->identity, | 
					
						
							|  |  |  | 					       args->interaction, | 
					
						
							|  |  |  | 					       args->flags, | 
					
						
							|  |  |  | 					       cancellable, | 
					
						
							|  |  |  | 					       &error); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |   if (error) | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |     g_task_return_error (task, error); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     g_task_return_int (task, (gssize)verify_result); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_tls_database_real_verify_chain_async (GTlsDatabase           *self, | 
					
						
							|  |  |  |                                         GTlsCertificate        *chain, | 
					
						
							|  |  |  |                                         const gchar            *purpose, | 
					
						
							|  |  |  |                                         GSocketConnectable     *identity, | 
					
						
							|  |  |  |                                         GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                                         GTlsDatabaseVerifyFlags flags, | 
					
						
							|  |  |  |                                         GCancellable           *cancellable, | 
					
						
							|  |  |  |                                         GAsyncReadyCallback     callback, | 
					
						
							|  |  |  |                                         gpointer                user_data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   GTask *task; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |   AsyncVerifyChain *args; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   args = g_slice_new0 (AsyncVerifyChain); | 
					
						
							|  |  |  |   args->chain = g_object_ref (chain); | 
					
						
							|  |  |  |   args->purpose = g_strdup (purpose); | 
					
						
							|  |  |  |   args->identity = identity ? g_object_ref (identity) : NULL; | 
					
						
							|  |  |  |   args->interaction = interaction ? g_object_ref (interaction) : NULL; | 
					
						
							|  |  |  |   args->flags = flags; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   task = g_task_new (self, cancellable, callback, user_data); | 
					
						
							| 
									
										
										
										
											2016-06-16 19:39:38 -04:00
										 |  |  |   g_task_set_source_tag (task, g_tls_database_real_verify_chain_async); | 
					
						
							| 
									
										
										
										
											2020-06-25 23:36:08 +01:00
										 |  |  |   g_task_set_name (task, "[gio] verify TLS chain"); | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   g_task_set_task_data (task, args, async_verify_chain_free); | 
					
						
							|  |  |  |   g_task_run_in_thread (task, async_verify_chain_thread); | 
					
						
							|  |  |  |   g_object_unref (task); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static GTlsCertificateFlags | 
					
						
							|  |  |  | g_tls_database_real_verify_chain_finish (GTlsDatabase          *self, | 
					
						
							|  |  |  |                                          GAsyncResult          *result, | 
					
						
							|  |  |  |                                          GError               **error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   GTlsCertificateFlags ret; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   g_return_val_if_fail (g_task_is_valid (result, self), G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   ret = (GTlsCertificateFlags)g_task_propagate_int (G_TASK (result), error); | 
					
						
							|  |  |  |   if (ret == (GTlsCertificateFlags)-1) | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |     return G_TLS_CERTIFICATE_GENERIC_ERROR; | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   else | 
					
						
							|  |  |  |     return ret; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |   gchar *handle; | 
					
						
							|  |  |  |   GTlsInteraction *interaction; | 
					
						
							|  |  |  |   GTlsDatabaseLookupFlags flags; | 
					
						
							|  |  |  | } AsyncLookupCertificateForHandle; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | async_lookup_certificate_for_handle_free (gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   AsyncLookupCertificateForHandle *args = data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_free (args->handle); | 
					
						
							|  |  |  |   g_clear_object (&args->interaction); | 
					
						
							|  |  |  |   g_slice_free (AsyncLookupCertificateForHandle, args); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  | async_lookup_certificate_for_handle_thread (GTask         *task, | 
					
						
							|  |  |  | 					    gpointer       object, | 
					
						
							|  |  |  | 					    gpointer       task_data, | 
					
						
							|  |  |  | 					    GCancellable  *cancellable) | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   AsyncLookupCertificateForHandle *args = task_data; | 
					
						
							|  |  |  |   GTlsCertificate *result; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |   GError *error = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   result = g_tls_database_lookup_certificate_for_handle (G_TLS_DATABASE (object), | 
					
						
							|  |  |  | 							 args->handle, | 
					
						
							|  |  |  | 							 args->interaction, | 
					
						
							|  |  |  | 							 args->flags, | 
					
						
							|  |  |  | 							 cancellable, | 
					
						
							|  |  |  | 							 &error); | 
					
						
							|  |  |  |   if (result) | 
					
						
							|  |  |  |     g_task_return_pointer (task, result, g_object_unref); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     g_task_return_error (task, error); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_tls_database_real_lookup_certificate_for_handle_async (GTlsDatabase           *self, | 
					
						
							|  |  |  |                                                          const gchar            *handle, | 
					
						
							|  |  |  |                                                          GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                                                          GTlsDatabaseLookupFlags flags, | 
					
						
							|  |  |  |                                                          GCancellable           *cancellable, | 
					
						
							|  |  |  |                                                          GAsyncReadyCallback     callback, | 
					
						
							|  |  |  |                                                          gpointer                user_data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   GTask *task; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |   AsyncLookupCertificateForHandle *args; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   args = g_slice_new0 (AsyncLookupCertificateForHandle); | 
					
						
							|  |  |  |   args->handle = g_strdup (handle); | 
					
						
							|  |  |  |   args->interaction = interaction ? g_object_ref (interaction) : NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   task = g_task_new (self, cancellable, callback, user_data); | 
					
						
							| 
									
										
										
										
											2016-06-16 19:39:38 -04:00
										 |  |  |   g_task_set_source_tag (task, | 
					
						
							|  |  |  |                          g_tls_database_real_lookup_certificate_for_handle_async); | 
					
						
							| 
									
										
										
										
											2020-06-25 23:36:08 +01:00
										 |  |  |   g_task_set_name (task, "[gio] lookup TLS certificate"); | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   g_task_set_task_data (task, args, async_lookup_certificate_for_handle_free); | 
					
						
							|  |  |  |   g_task_run_in_thread (task, async_lookup_certificate_for_handle_thread); | 
					
						
							|  |  |  |   g_object_unref (task); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static GTlsCertificate* | 
					
						
							|  |  |  | g_tls_database_real_lookup_certificate_for_handle_finish (GTlsDatabase          *self, | 
					
						
							|  |  |  |                                                           GAsyncResult          *result, | 
					
						
							|  |  |  |                                                           GError               **error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   g_return_val_if_fail (g_task_is_valid (result, self), NULL); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   return g_task_propagate_pointer (G_TASK (result), error); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |   GTlsCertificate *certificate; | 
					
						
							|  |  |  |   GTlsInteraction *interaction; | 
					
						
							|  |  |  |   GTlsDatabaseLookupFlags flags; | 
					
						
							|  |  |  | } AsyncLookupCertificateIssuer; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | async_lookup_certificate_issuer_free (gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   AsyncLookupCertificateIssuer *args = data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_clear_object (&args->certificate); | 
					
						
							|  |  |  |   g_clear_object (&args->interaction); | 
					
						
							|  |  |  |   g_slice_free (AsyncLookupCertificateIssuer, args); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  | async_lookup_certificate_issuer_thread (GTask         *task, | 
					
						
							|  |  |  | 					gpointer       object, | 
					
						
							|  |  |  | 					gpointer       task_data, | 
					
						
							|  |  |  | 					GCancellable  *cancellable) | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   AsyncLookupCertificateIssuer *args = task_data; | 
					
						
							|  |  |  |   GTlsCertificate *issuer; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |   GError *error = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   issuer = g_tls_database_lookup_certificate_issuer (G_TLS_DATABASE (object), | 
					
						
							|  |  |  | 						     args->certificate, | 
					
						
							|  |  |  | 						     args->interaction, | 
					
						
							|  |  |  | 						     args->flags, | 
					
						
							|  |  |  | 						     cancellable, | 
					
						
							|  |  |  | 						     &error); | 
					
						
							|  |  |  |   if (issuer) | 
					
						
							|  |  |  |     g_task_return_pointer (task, issuer, g_object_unref); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     g_task_return_error (task, error); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_tls_database_real_lookup_certificate_issuer_async (GTlsDatabase           *self, | 
					
						
							|  |  |  |                                                      GTlsCertificate        *certificate, | 
					
						
							|  |  |  |                                                      GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                                                      GTlsDatabaseLookupFlags flags, | 
					
						
							|  |  |  |                                                      GCancellable           *cancellable, | 
					
						
							|  |  |  |                                                      GAsyncReadyCallback     callback, | 
					
						
							|  |  |  |                                                      gpointer                user_data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   GTask *task; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |   AsyncLookupCertificateIssuer *args; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   args = g_slice_new0 (AsyncLookupCertificateIssuer); | 
					
						
							|  |  |  |   args->certificate = g_object_ref (certificate); | 
					
						
							|  |  |  |   args->flags = flags; | 
					
						
							|  |  |  |   args->interaction = interaction ? g_object_ref (interaction) : NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   task = g_task_new (self, cancellable, callback, user_data); | 
					
						
							| 
									
										
										
										
											2016-06-16 19:39:38 -04:00
										 |  |  |   g_task_set_source_tag (task, | 
					
						
							|  |  |  |                          g_tls_database_real_lookup_certificate_issuer_async); | 
					
						
							| 
									
										
										
										
											2020-06-25 23:36:08 +01:00
										 |  |  |   g_task_set_name (task, "[gio] lookup certificate issuer"); | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   g_task_set_task_data (task, args, async_lookup_certificate_issuer_free); | 
					
						
							|  |  |  |   g_task_run_in_thread (task, async_lookup_certificate_issuer_thread); | 
					
						
							|  |  |  |   g_object_unref (task); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  | static GTlsCertificate * | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | g_tls_database_real_lookup_certificate_issuer_finish (GTlsDatabase          *self, | 
					
						
							|  |  |  |                                                       GAsyncResult          *result, | 
					
						
							|  |  |  |                                                       GError               **error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   g_return_val_if_fail (g_task_is_valid (result, self), NULL); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   return g_task_propagate_pointer (G_TASK (result), error); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |   GByteArray *issuer; | 
					
						
							|  |  |  |   GTlsInteraction *interaction; | 
					
						
							|  |  |  |   GTlsDatabaseLookupFlags flags; | 
					
						
							|  |  |  | } AsyncLookupCertificatesIssuedBy; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | async_lookup_certificates_issued_by_free (gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   AsyncLookupCertificatesIssuedBy *args = data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_byte_array_unref (args->issuer); | 
					
						
							|  |  |  |   g_clear_object (&args->interaction); | 
					
						
							|  |  |  |   g_slice_free (AsyncLookupCertificatesIssuedBy, args); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  | async_lookup_certificates_free_certificates (gpointer data) | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   GList *list = data; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   g_list_free_full (list, g_object_unref); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  | static void | 
					
						
							|  |  |  | async_lookup_certificates_issued_by_thread (GTask         *task, | 
					
						
							|  |  |  | 					    gpointer       object, | 
					
						
							|  |  |  | 					    gpointer       task_data, | 
					
						
							|  |  |  |                                             GCancellable  *cancellable) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   AsyncLookupCertificatesIssuedBy *args = task_data; | 
					
						
							|  |  |  |   GList *results; | 
					
						
							|  |  |  |   GError *error = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   results = g_tls_database_lookup_certificates_issued_by (G_TLS_DATABASE (object), | 
					
						
							|  |  |  | 							  args->issuer, | 
					
						
							|  |  |  | 							  args->interaction, | 
					
						
							|  |  |  | 							  args->flags, | 
					
						
							|  |  |  | 							  cancellable, | 
					
						
							|  |  |  | 							  &error); | 
					
						
							|  |  |  |   if (results) | 
					
						
							|  |  |  |     g_task_return_pointer (task, results, async_lookup_certificates_free_certificates); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     g_task_return_error (task, error); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_tls_database_real_lookup_certificates_issued_by_async (GTlsDatabase           *self, | 
					
						
							|  |  |  |                                                          GByteArray             *issuer, | 
					
						
							|  |  |  |                                                          GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                                                          GTlsDatabaseLookupFlags flags, | 
					
						
							|  |  |  |                                                          GCancellable           *cancellable, | 
					
						
							|  |  |  |                                                          GAsyncReadyCallback     callback, | 
					
						
							|  |  |  |                                                          gpointer                user_data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   GTask *task; | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |   AsyncLookupCertificatesIssuedBy *args; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   args = g_slice_new0 (AsyncLookupCertificatesIssuedBy); | 
					
						
							|  |  |  |   args->issuer = g_byte_array_ref (issuer); | 
					
						
							|  |  |  |   args->flags = flags; | 
					
						
							|  |  |  |   args->interaction = interaction ? g_object_ref (interaction) : NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   task = g_task_new (self, cancellable, callback, user_data); | 
					
						
							| 
									
										
										
										
											2016-06-16 19:39:38 -04:00
										 |  |  |   g_task_set_source_tag (task, | 
					
						
							|  |  |  |                          g_tls_database_real_lookup_certificates_issued_by_async); | 
					
						
							| 
									
										
										
										
											2020-06-25 23:36:08 +01:00
										 |  |  |   g_task_set_name (task, "[gio] lookup certificates issued by"); | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   g_task_set_task_data (task, args, async_lookup_certificates_issued_by_free); | 
					
						
							|  |  |  |   g_task_run_in_thread (task, async_lookup_certificates_issued_by_thread); | 
					
						
							|  |  |  |   g_object_unref (task); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  | static GList * | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | g_tls_database_real_lookup_certificates_issued_by_finish (GTlsDatabase          *self, | 
					
						
							|  |  |  |                                                           GAsyncResult          *result, | 
					
						
							|  |  |  |                                                           GError               **error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   g_return_val_if_fail (g_task_is_valid (result, self), NULL); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-02 15:48:22 -04:00
										 |  |  |   return g_task_propagate_pointer (G_TASK (result), error); | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_tls_database_class_init (GTlsDatabaseClass *klass) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   klass->verify_chain_async = g_tls_database_real_verify_chain_async; | 
					
						
							|  |  |  |   klass->verify_chain_finish = g_tls_database_real_verify_chain_finish; | 
					
						
							|  |  |  |   klass->lookup_certificate_for_handle_async = g_tls_database_real_lookup_certificate_for_handle_async; | 
					
						
							|  |  |  |   klass->lookup_certificate_for_handle_finish = g_tls_database_real_lookup_certificate_for_handle_finish; | 
					
						
							|  |  |  |   klass->lookup_certificate_issuer_async = g_tls_database_real_lookup_certificate_issuer_async; | 
					
						
							|  |  |  |   klass->lookup_certificate_issuer_finish = g_tls_database_real_lookup_certificate_issuer_finish; | 
					
						
							|  |  |  |   klass->lookup_certificates_issued_by_async = g_tls_database_real_lookup_certificates_issued_by_async; | 
					
						
							|  |  |  |   klass->lookup_certificates_issued_by_finish = g_tls_database_real_lookup_certificates_issued_by_finish; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_verify_chain: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @chain: a #GTlsCertificate chain | 
					
						
							|  |  |  |  * @purpose: the purpose that this certificate chain will be used for. | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @identity: (nullable): the expected peer identity | 
					
						
							|  |  |  |  * @interaction: (nullable): used to interact with the user if necessary | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @flags: additional verify flags | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @cancellable: (nullable): a #GCancellable, or %NULL | 
					
						
							|  |  |  |  * @error: (nullable): a #GError, or %NULL | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-08-04 09:35:16 -05:00
										 |  |  |  * Determines the validity of a certificate chain, outside the context | 
					
						
							|  |  |  |  * of a TLS session. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @chain is a chain of #GTlsCertificate objects each pointing to the next | 
					
						
							| 
									
										
										
										
											2021-08-04 09:35:16 -05:00
										 |  |  |  * certificate in the chain by its #GTlsCertificate:issuer property. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @purpose describes the purpose (or usage) for which the certificate | 
					
						
							| 
									
										
										
										
											2022-03-04 16:21:55 +00:00
										 |  |  |  * is being used. Typically @purpose will be set to %G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * which means that the certificate is being used to authenticate a server | 
					
						
							|  |  |  |  * (and we are acting as the client). | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2020-05-04 17:13:39 -05:00
										 |  |  |  * The @identity is used to ensure the server certificate is valid for | 
					
						
							|  |  |  |  * the expected peer identity. If the identity does not match the | 
					
						
							|  |  |  |  * certificate, %G_TLS_CERTIFICATE_BAD_IDENTITY will be set in the | 
					
						
							|  |  |  |  * return value. If @identity is %NULL, that bit will never be set in | 
					
						
							|  |  |  |  * the return value. The peer identity may also be used to check for | 
					
						
							|  |  |  |  * pinned certificates (trust exceptions) in the database. These may | 
					
						
							|  |  |  |  * override the normal verification process on a host-by-host basis. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Currently there are no @flags, and %G_TLS_DATABASE_VERIFY_NONE should be | 
					
						
							|  |  |  |  * used. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-03-22 19:23:46 +01:00
										 |  |  |  * If @chain is found to be valid, then the return value will be 0. If | 
					
						
							| 
									
										
										
										
											2021-08-04 14:57:05 -05:00
										 |  |  |  * @chain is found to be invalid, then the return value will indicate at | 
					
						
							|  |  |  |  * least one problem found. If the function is unable to determine | 
					
						
							|  |  |  |  * whether @chain is valid (for example, because @cancellable is | 
					
						
							|  |  |  |  * triggered before it completes) then the return value will be | 
					
						
							|  |  |  |  * %G_TLS_CERTIFICATE_GENERIC_ERROR and @error will be set accordingly. | 
					
						
							|  |  |  |  * @error is not set when @chain is successfully analyzed but found to | 
					
						
							|  |  |  |  * be invalid. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * GLib guarantees that if certificate verification fails, at least one | 
					
						
							|  |  |  |  * error will be set in the return value, 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. | 
					
						
							| 
									
										
										
										
											2017-03-22 19:23:46 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-08-04 09:35:16 -05:00
										 |  |  |  * Prior to GLib 2.48, GLib's default TLS backend modified @chain to | 
					
						
							|  |  |  |  * represent the certification path built by #GTlsDatabase during | 
					
						
							|  |  |  |  * certificate verification by adjusting the #GTlsCertificate:issuer | 
					
						
							|  |  |  |  * property of each certificate in @chain. Since GLib 2.48, this no | 
					
						
							|  |  |  |  * longer occurs, so you cannot rely on #GTlsCertificate:issuer to | 
					
						
							|  |  |  |  * represent the actual certification path used during certificate | 
					
						
							|  |  |  |  * verification. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Because TLS session context is not used, #GTlsDatabase may not | 
					
						
							|  |  |  |  * perform as many checks on the certificates as #GTlsConnection would. | 
					
						
							| 
									
										
										
										
											2021-11-09 17:14:30 -06:00
										 |  |  |  * For example, certificate constraints may not be honored, and | 
					
						
							|  |  |  |  * revocation checks may not be performed. The best way to verify TLS | 
					
						
							| 
									
										
										
										
											2021-08-04 09:35:16 -05:00
										 |  |  |  * certificates used by a TLS connection is to let #GTlsConnection | 
					
						
							|  |  |  |  * handle the verification. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The TLS backend may attempt to look up and add missing certificates | 
					
						
							| 
									
										
										
										
											2021-11-09 13:07:00 -06:00
										 |  |  |  * to the chain. This may involve HTTP requests to download missing | 
					
						
							|  |  |  |  * certificates. | 
					
						
							| 
									
										
										
										
											2021-08-04 09:35:16 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This function can block. Use g_tls_database_verify_chain_async() to | 
					
						
							|  |  |  |  * perform the verification operation asynchronously. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-19 19:35:23 -05:00
										 |  |  |  * Returns: the appropriate #GTlsCertificateFlags which represents the | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * result of verification. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | GTlsCertificateFlags | 
					
						
							|  |  |  | g_tls_database_verify_chain (GTlsDatabase           *self, | 
					
						
							|  |  |  |                              GTlsCertificate        *chain, | 
					
						
							|  |  |  |                              const gchar            *purpose, | 
					
						
							|  |  |  |                              GSocketConnectable     *identity, | 
					
						
							|  |  |  |                              GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                              GTlsDatabaseVerifyFlags flags, | 
					
						
							|  |  |  |                              GCancellable           *cancellable, | 
					
						
							|  |  |  |                              GError                **error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_DATABASE (self), G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_CERTIFICATE (chain), | 
					
						
							|  |  |  |                         G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  |   g_return_val_if_fail (purpose, G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  |   g_return_val_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction), | 
					
						
							|  |  |  |                         G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  |   g_return_val_if_fail (identity == NULL || G_IS_SOCKET_CONNECTABLE (identity), | 
					
						
							|  |  |  |                         G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  |   g_return_val_if_fail (error == NULL || *error == NULL, G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->verify_chain, | 
					
						
							|  |  |  |                         G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return G_TLS_DATABASE_GET_CLASS (self)->verify_chain (self, | 
					
						
							|  |  |  |                                                         chain, | 
					
						
							|  |  |  |                                                         purpose, | 
					
						
							|  |  |  |                                                         identity, | 
					
						
							|  |  |  |                                                         interaction, | 
					
						
							|  |  |  |                                                         flags, | 
					
						
							|  |  |  |                                                         cancellable, | 
					
						
							|  |  |  |                                                         error); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_verify_chain_async: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @chain: a #GTlsCertificate chain | 
					
						
							|  |  |  |  * @purpose: the purpose that this certificate chain will be used for. | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @identity: (nullable): the expected peer identity | 
					
						
							|  |  |  |  * @interaction: (nullable): used to interact with the user if necessary | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @flags: additional verify flags | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @cancellable: (nullable): a #GCancellable, or %NULL | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @callback: callback to call when the operation completes | 
					
						
							|  |  |  |  * @user_data: the data to pass to the callback function | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-03-22 19:23:46 +01:00
										 |  |  |  * Asynchronously determines the validity of a certificate chain after | 
					
						
							|  |  |  |  * looking up and adding any missing certificates to the chain. See | 
					
						
							|  |  |  |  * g_tls_database_verify_chain() for more information. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_tls_database_verify_chain_async (GTlsDatabase           *self, | 
					
						
							|  |  |  |                                    GTlsCertificate        *chain, | 
					
						
							|  |  |  |                                    const gchar            *purpose, | 
					
						
							|  |  |  |                                    GSocketConnectable     *identity, | 
					
						
							|  |  |  |                                    GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                                    GTlsDatabaseVerifyFlags flags, | 
					
						
							|  |  |  |                                    GCancellable           *cancellable, | 
					
						
							|  |  |  |                                    GAsyncReadyCallback     callback, | 
					
						
							|  |  |  |                                    gpointer                user_data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_TLS_DATABASE (self)); | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_TLS_CERTIFICATE (chain)); | 
					
						
							|  |  |  |   g_return_if_fail (purpose != NULL); | 
					
						
							|  |  |  |   g_return_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction)); | 
					
						
							|  |  |  |   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); | 
					
						
							|  |  |  |   g_return_if_fail (identity == NULL || G_IS_SOCKET_CONNECTABLE (identity)); | 
					
						
							|  |  |  |   g_return_if_fail (callback != NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_return_if_fail (G_TLS_DATABASE_GET_CLASS (self)->verify_chain_async); | 
					
						
							|  |  |  |   G_TLS_DATABASE_GET_CLASS (self)->verify_chain_async (self, | 
					
						
							|  |  |  |                                                        chain, | 
					
						
							|  |  |  |                                                        purpose, | 
					
						
							|  |  |  |                                                        identity, | 
					
						
							|  |  |  |                                                        interaction, | 
					
						
							|  |  |  |                                                        flags, | 
					
						
							|  |  |  |                                                        cancellable, | 
					
						
							|  |  |  |                                                        callback, | 
					
						
							|  |  |  |                                                        user_data); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_verify_chain_finish: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @result: a #GAsyncResult. | 
					
						
							|  |  |  |  * @error: a #GError pointer, or %NULL | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Finish an asynchronous verify chain operation. See | 
					
						
							| 
									
										
										
										
											2017-03-22 19:23:46 +01:00
										 |  |  |  * g_tls_database_verify_chain() for more information. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * If @chain is found to be valid, then the return value will be 0. If | 
					
						
							|  |  |  |  * @chain is found to be invalid, then the return value will indicate | 
					
						
							|  |  |  |  * the problems found. If the function is unable to determine whether | 
					
						
							|  |  |  |  * @chain is valid or not (eg, because @cancellable is triggered | 
					
						
							|  |  |  |  * before it completes) then the return value will be | 
					
						
							|  |  |  |  * %G_TLS_CERTIFICATE_GENERIC_ERROR and @error will be set | 
					
						
							|  |  |  |  * accordingly. @error is not set when @chain is successfully analyzed | 
					
						
							|  |  |  |  * but found to be invalid. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-19 19:35:23 -05:00
										 |  |  |  * Returns: the appropriate #GTlsCertificateFlags which represents the | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * result of verification. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | GTlsCertificateFlags | 
					
						
							|  |  |  | g_tls_database_verify_chain_finish (GTlsDatabase          *self, | 
					
						
							|  |  |  |                                     GAsyncResult          *result, | 
					
						
							|  |  |  |                                     GError               **error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_DATABASE (self), G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_ASYNC_RESULT (result), G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  |   g_return_val_if_fail (error == NULL || *error == NULL, G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->verify_chain_finish, | 
					
						
							|  |  |  |                         G_TLS_CERTIFICATE_GENERIC_ERROR); | 
					
						
							|  |  |  |   return G_TLS_DATABASE_GET_CLASS (self)->verify_chain_finish (self, | 
					
						
							|  |  |  |                                                                result, | 
					
						
							|  |  |  |                                                                error); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_create_certificate_handle: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @certificate: certificate for which to create a handle. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Create a handle string for the certificate. The database will only be able | 
					
						
							|  |  |  |  * to create a handle for certificates that originate from the database. In | 
					
						
							|  |  |  |  * cases where the database cannot create a handle for a certificate, %NULL | 
					
						
							|  |  |  |  * will be returned. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This handle should be stable across various instances of the application, | 
					
						
							|  |  |  |  * and between applications. If a certificate is modified in the database, | 
					
						
							|  |  |  |  * then it is not guaranteed that this handle will continue to point to it. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-05-21 00:27:36 -07:00
										 |  |  |  * Returns: (nullable): a newly allocated string containing the | 
					
						
							|  |  |  |  * handle. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | gchar* | 
					
						
							|  |  |  | g_tls_database_create_certificate_handle (GTlsDatabase            *self, | 
					
						
							|  |  |  |                                           GTlsCertificate         *certificate) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_CERTIFICATE (certificate), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->create_certificate_handle, NULL); | 
					
						
							|  |  |  |   return G_TLS_DATABASE_GET_CLASS (self)->create_certificate_handle (self, | 
					
						
							|  |  |  |                                                                      certificate); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificate_for_handle: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @handle: a certificate handle | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @interaction: (nullable): used to interact with the user if necessary | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @flags: Flags which affect the lookup. | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @cancellable: (nullable): a #GCancellable, or %NULL | 
					
						
							|  |  |  |  * @error: (nullable): a #GError, or %NULL | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-04-26 12:12:31 +01:00
										 |  |  |  * Look up a certificate by its handle. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-02-19 15:51:09 +00:00
										 |  |  |  * The handle should have been created by calling | 
					
						
							|  |  |  |  * g_tls_database_create_certificate_handle() on a #GTlsDatabase object of | 
					
						
							|  |  |  |  * the same TLS backend. The handle is designed to remain valid across | 
					
						
							|  |  |  |  * instantiations of the database. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * If the handle is no longer valid, or does not point to a certificate in | 
					
						
							|  |  |  |  * this database, then %NULL will be returned. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This function can block, use g_tls_database_lookup_certificate_for_handle_async() to perform | 
					
						
							|  |  |  |  * the lookup operation asynchronously. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * Returns: (transfer full) (nullable): a newly allocated | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * #GTlsCertificate, or %NULL. Use g_object_unref() to release the certificate. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | GTlsCertificate* | 
					
						
							|  |  |  | g_tls_database_lookup_certificate_for_handle (GTlsDatabase            *self, | 
					
						
							|  |  |  |                                               const gchar             *handle, | 
					
						
							|  |  |  |                                               GTlsInteraction         *interaction, | 
					
						
							|  |  |  |                                               GTlsDatabaseLookupFlags  flags, | 
					
						
							|  |  |  |                                               GCancellable            *cancellable, | 
					
						
							|  |  |  |                                               GError                 **error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (handle != NULL, NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (error == NULL || *error == NULL, NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle, NULL); | 
					
						
							|  |  |  |   return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle (self, | 
					
						
							|  |  |  |                                                                          handle, | 
					
						
							|  |  |  |                                                                          interaction, | 
					
						
							|  |  |  |                                                                          flags, | 
					
						
							|  |  |  |                                                                          cancellable, | 
					
						
							|  |  |  |                                                                          error); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificate_for_handle_async: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @handle: a certificate handle | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @interaction: (nullable): used to interact with the user if necessary | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @flags: Flags which affect the lookup. | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @cancellable: (nullable): a #GCancellable, or %NULL | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @callback: callback to call when the operation completes | 
					
						
							|  |  |  |  * @user_data: the data to pass to the callback function | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-04-26 12:12:31 +01:00
										 |  |  |  * Asynchronously look up a certificate by its handle in the database. See | 
					
						
							| 
									
										
										
										
											2012-02-19 15:51:09 +00:00
										 |  |  |  * g_tls_database_lookup_certificate_for_handle() for more information. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_tls_database_lookup_certificate_for_handle_async (GTlsDatabase            *self, | 
					
						
							|  |  |  |                                                     const gchar             *handle, | 
					
						
							|  |  |  |                                                     GTlsInteraction         *interaction, | 
					
						
							|  |  |  |                                                     GTlsDatabaseLookupFlags  flags, | 
					
						
							|  |  |  |                                                     GCancellable            *cancellable, | 
					
						
							|  |  |  |                                                     GAsyncReadyCallback      callback, | 
					
						
							|  |  |  |                                                     gpointer                 user_data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_TLS_DATABASE (self)); | 
					
						
							|  |  |  |   g_return_if_fail (handle != NULL); | 
					
						
							|  |  |  |   g_return_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction)); | 
					
						
							|  |  |  |   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); | 
					
						
							|  |  |  |   g_return_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle_async); | 
					
						
							| 
									
										
										
										
											2011-08-17 03:01:14 -05:00
										 |  |  |   G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle_async (self, | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |                                                                                handle, | 
					
						
							|  |  |  |                                                                                interaction, | 
					
						
							|  |  |  |                                                                                flags, | 
					
						
							|  |  |  |                                                                                cancellable, | 
					
						
							|  |  |  |                                                                                callback, | 
					
						
							|  |  |  |                                                                                user_data); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificate_for_handle_finish: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @result: a #GAsyncResult. | 
					
						
							|  |  |  |  * @error: a #GError pointer, or %NULL | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Finish an asynchronous lookup of a certificate by its handle. See | 
					
						
							| 
									
										
										
										
											2019-03-07 17:36:49 +00:00
										 |  |  |  * g_tls_database_lookup_certificate_for_handle() for more information. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * If the handle is no longer valid, or does not point to a certificate in | 
					
						
							|  |  |  |  * this database, then %NULL will be returned. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-19 19:35:23 -05:00
										 |  |  |  * Returns: (transfer full): a newly allocated #GTlsCertificate object. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * Use g_object_unref() to release the certificate. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | GTlsCertificate* | 
					
						
							|  |  |  | g_tls_database_lookup_certificate_for_handle_finish (GTlsDatabase            *self, | 
					
						
							|  |  |  |                                                      GAsyncResult            *result, | 
					
						
							|  |  |  |                                                      GError                 **error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (error == NULL || *error == NULL, NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle_finish, NULL); | 
					
						
							|  |  |  |   return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_for_handle_finish (self, | 
					
						
							|  |  |  |                                                                                 result, | 
					
						
							|  |  |  |                                                                                 error); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificate_issuer: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @certificate: a #GTlsCertificate | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @interaction: (nullable): used to interact with the user if necessary | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @flags: flags which affect the lookup operation | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @cancellable: (nullable): a #GCancellable, or %NULL | 
					
						
							|  |  |  |  * @error: (nullable): a #GError, or %NULL | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-08-04 09:35:16 -05:00
										 |  |  |  * Look up the issuer of @certificate in the database. The | 
					
						
							|  |  |  |  * #GTlsCertificate:issuer property of @certificate is not modified, and | 
					
						
							|  |  |  |  * the two certificates are not hooked into a chain. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This function can block. Use g_tls_database_lookup_certificate_issuer_async() | 
					
						
							|  |  |  |  * to perform the lookup operation asynchronously. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Beware this function cannot be used to build certification paths. The | 
					
						
							|  |  |  |  * issuer certificate returned by this function may not be the same as | 
					
						
							|  |  |  |  * the certificate that would actually be used to construct a valid | 
					
						
							|  |  |  |  * certification path during certificate verification. | 
					
						
							|  |  |  |  * [RFC 4158](https://datatracker.ietf.org/doc/html/rfc4158) explains
 | 
					
						
							|  |  |  |  * why an issuer certificate cannot be naively assumed to be part of the | 
					
						
							|  |  |  |  * the certification path (though GLib's TLS backends may not follow the | 
					
						
							|  |  |  |  * path building strategies outlined in this RFC). Due to the complexity | 
					
						
							|  |  |  |  * of certification path building, GLib does not provide any way to know | 
					
						
							|  |  |  |  * which certification path will actually be used when verifying a TLS | 
					
						
							|  |  |  |  * certificate. Accordingly, this function cannot be used to make | 
					
						
							|  |  |  |  * security-related decisions. Only GLib itself should make security | 
					
						
							|  |  |  |  * decisions about TLS certificates. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-19 19:35:23 -05:00
										 |  |  |  * Returns: (transfer full): a newly allocated issuer #GTlsCertificate, | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * or %NULL. Use g_object_unref() to release the certificate. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | GTlsCertificate* | 
					
						
							|  |  |  | g_tls_database_lookup_certificate_issuer (GTlsDatabase           *self, | 
					
						
							|  |  |  |                                           GTlsCertificate        *certificate, | 
					
						
							|  |  |  |                                           GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                                           GTlsDatabaseLookupFlags flags, | 
					
						
							|  |  |  |                                           GCancellable           *cancellable, | 
					
						
							|  |  |  |                                           GError                **error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_CERTIFICATE (certificate), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (error == NULL || *error == NULL, NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer, NULL); | 
					
						
							|  |  |  |   return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer (self, | 
					
						
							|  |  |  |                                                                      certificate, | 
					
						
							|  |  |  |                                                                      interaction, | 
					
						
							|  |  |  |                                                                      flags, | 
					
						
							|  |  |  |                                                                      cancellable, | 
					
						
							|  |  |  |                                                                      error); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificate_issuer_async: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @certificate: a #GTlsCertificate | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @interaction: (nullable): used to interact with the user if necessary | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @flags: flags which affect the lookup operation | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @cancellable: (nullable): a #GCancellable, or %NULL | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @callback: callback to call when the operation completes | 
					
						
							|  |  |  |  * @user_data: the data to pass to the callback function | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-04-26 12:12:31 +01:00
										 |  |  |  * Asynchronously look up the issuer of @certificate in the database. See | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * g_tls_database_lookup_certificate_issuer() for more information. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_tls_database_lookup_certificate_issuer_async (GTlsDatabase           *self, | 
					
						
							|  |  |  |                                                 GTlsCertificate        *certificate, | 
					
						
							|  |  |  |                                                 GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                                                 GTlsDatabaseLookupFlags flags, | 
					
						
							|  |  |  |                                                 GCancellable           *cancellable, | 
					
						
							|  |  |  |                                                 GAsyncReadyCallback     callback, | 
					
						
							|  |  |  |                                                 gpointer                user_data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_TLS_DATABASE (self)); | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_TLS_CERTIFICATE (certificate)); | 
					
						
							|  |  |  |   g_return_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction)); | 
					
						
							|  |  |  |   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); | 
					
						
							|  |  |  |   g_return_if_fail (callback != NULL); | 
					
						
							|  |  |  |   g_return_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer_async); | 
					
						
							|  |  |  |   G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer_async (self, | 
					
						
							|  |  |  |                                                         certificate, | 
					
						
							|  |  |  |                                                         interaction, | 
					
						
							|  |  |  |                                                         flags, | 
					
						
							|  |  |  |                                                         cancellable, | 
					
						
							|  |  |  |                                                         callback, | 
					
						
							|  |  |  |                                                         user_data); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificate_issuer_finish: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @result: a #GAsyncResult. | 
					
						
							|  |  |  |  * @error: a #GError pointer, or %NULL | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Finish an asynchronous lookup issuer operation. See | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificate_issuer() for more information. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-19 19:35:23 -05:00
										 |  |  |  * Returns: (transfer full): a newly allocated issuer #GTlsCertificate, | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * or %NULL. Use g_object_unref() to release the certificate. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | GTlsCertificate* | 
					
						
							|  |  |  | g_tls_database_lookup_certificate_issuer_finish (GTlsDatabase          *self, | 
					
						
							|  |  |  |                                                  GAsyncResult          *result, | 
					
						
							|  |  |  |                                                  GError               **error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (error == NULL || *error == NULL, NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer_finish, NULL); | 
					
						
							|  |  |  |   return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificate_issuer_finish (self, | 
					
						
							|  |  |  |                                                                 result, | 
					
						
							|  |  |  |                                                                 error); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificates_issued_by: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @issuer_raw_dn: a #GByteArray which holds the DER encoded issuer DN. | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @interaction: (nullable): used to interact with the user if necessary | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @flags: Flags which affect the lookup operation. | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @cancellable: (nullable): a #GCancellable, or %NULL | 
					
						
							|  |  |  |  * @error: (nullable): a #GError, or %NULL | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-04-26 12:12:31 +01:00
										 |  |  |  * Look up certificates issued by this issuer in the database. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This function can block, use g_tls_database_lookup_certificates_issued_by_async() to perform | 
					
						
							|  |  |  |  * the lookup operation asynchronously. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-19 19:35:23 -05:00
										 |  |  |  * Returns: (transfer full) (element-type GTlsCertificate): a newly allocated list of #GTlsCertificate | 
					
						
							| 
									
										
										
										
											2012-01-07 09:54:53 -08:00
										 |  |  |  * objects. Use g_object_unref() on each certificate, and g_list_free() on the release the list. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | GList* | 
					
						
							|  |  |  | g_tls_database_lookup_certificates_issued_by (GTlsDatabase           *self, | 
					
						
							|  |  |  |                                               GByteArray             *issuer_raw_dn, | 
					
						
							|  |  |  |                                               GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                                               GTlsDatabaseLookupFlags flags, | 
					
						
							|  |  |  |                                               GCancellable           *cancellable, | 
					
						
							|  |  |  |                                               GError                **error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (issuer_raw_dn, NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (error == NULL || *error == NULL, NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by, NULL); | 
					
						
							|  |  |  |   return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by (self, | 
					
						
							|  |  |  |                                                                          issuer_raw_dn, | 
					
						
							|  |  |  |                                                                          interaction, | 
					
						
							|  |  |  |                                                                          flags, | 
					
						
							|  |  |  |                                                                          cancellable, | 
					
						
							|  |  |  |                                                                          error); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificates_issued_by_async: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @issuer_raw_dn: a #GByteArray which holds the DER encoded issuer DN. | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @interaction: (nullable): used to interact with the user if necessary | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @flags: Flags which affect the lookup operation. | 
					
						
							| 
									
										
										
										
											2016-10-28 18:29:02 -07:00
										 |  |  |  * @cancellable: (nullable): a #GCancellable, or %NULL | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * @callback: callback to call when the operation completes | 
					
						
							|  |  |  |  * @user_data: the data to pass to the callback function | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-04-26 12:12:31 +01:00
										 |  |  |  * Asynchronously look up certificates issued by this issuer in the database. See | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * g_tls_database_lookup_certificates_issued_by() for more information. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The database may choose to hold a reference to the issuer byte array for the duration | 
					
						
							| 
									
										
										
										
											2023-08-01 03:30:07 -03:00
										 |  |  |  * of this asynchronous operation. The byte array should not be modified during | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * this time. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | g_tls_database_lookup_certificates_issued_by_async (GTlsDatabase           *self, | 
					
						
							|  |  |  |                                                     GByteArray             *issuer_raw_dn, | 
					
						
							|  |  |  |                                                     GTlsInteraction        *interaction, | 
					
						
							|  |  |  |                                                     GTlsDatabaseLookupFlags flags, | 
					
						
							|  |  |  |                                                     GCancellable           *cancellable, | 
					
						
							|  |  |  |                                                     GAsyncReadyCallback     callback, | 
					
						
							|  |  |  |                                                     gpointer                user_data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_if_fail (G_IS_TLS_DATABASE (self)); | 
					
						
							|  |  |  |   g_return_if_fail (issuer_raw_dn != NULL); | 
					
						
							|  |  |  |   g_return_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction)); | 
					
						
							|  |  |  |   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); | 
					
						
							|  |  |  |   g_return_if_fail (callback != NULL); | 
					
						
							|  |  |  |   g_return_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by_async); | 
					
						
							|  |  |  |   G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by_async (self, | 
					
						
							|  |  |  |                                                                         issuer_raw_dn, | 
					
						
							|  |  |  |                                                                         interaction, | 
					
						
							|  |  |  |                                                                         flags, | 
					
						
							|  |  |  |                                                                         cancellable, | 
					
						
							|  |  |  |                                                                         callback, | 
					
						
							|  |  |  |                                                                         user_data); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificates_issued_by_finish: | 
					
						
							|  |  |  |  * @self: a #GTlsDatabase | 
					
						
							|  |  |  |  * @result: a #GAsyncResult. | 
					
						
							|  |  |  |  * @error: a #GError pointer, or %NULL | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Finish an asynchronous lookup of certificates. See | 
					
						
							|  |  |  |  * g_tls_database_lookup_certificates_issued_by() for more information. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-19 19:35:23 -05:00
										 |  |  |  * Returns: (transfer full) (element-type GTlsCertificate): a newly allocated list of #GTlsCertificate | 
					
						
							| 
									
										
										
										
											2013-01-13 20:05:17 +01:00
										 |  |  |  * objects. Use g_object_unref() on each certificate, and g_list_free() on the release the list. | 
					
						
							| 
									
										
										
										
											2011-08-04 08:54:55 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | GList* | 
					
						
							|  |  |  | g_tls_database_lookup_certificates_issued_by_finish (GTlsDatabase          *self, | 
					
						
							|  |  |  |                                                      GAsyncResult          *result, | 
					
						
							|  |  |  |                                                      GError               **error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_TLS_DATABASE (self), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (error == NULL || *error == NULL, NULL); | 
					
						
							|  |  |  |   g_return_val_if_fail (G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by_finish, NULL); | 
					
						
							|  |  |  |   return G_TLS_DATABASE_GET_CLASS (self)->lookup_certificates_issued_by_finish (self, | 
					
						
							|  |  |  |                                                                                 result, | 
					
						
							|  |  |  |                                                                                 error); | 
					
						
							|  |  |  | } |