[glib/tls-database] Add @purpose argument to GTlsDatabase::verify_chain()
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/tls-database] Add @purpose argument to GTlsDatabase::verify_chain()
- Date: Tue, 28 Dec 2010 02:36:25 +0000 (UTC)
commit 8baf18a27162ac4782c766a00f094f6a459935c8
Author: Stef Walter <stefw collabora co uk>
Date: Mon Dec 27 18:10:19 2010 -0600
Add @purpose argument to GTlsDatabase::verify_chain()
So that we can use the verify_chain() method for both client and
server connections.
gio/gtlsdatabase.c | 10 ++++++++++
gio/gtlsdatabase.h | 7 +++++++
2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gio/gtlsdatabase.c b/gio/gtlsdatabase.c
index 587c048..d233d16 100644
--- a/gio/gtlsdatabase.c
+++ b/gio/gtlsdatabase.c
@@ -38,6 +38,7 @@ g_tls_database_init (GTlsDatabase *cert)
typedef struct _AsyncVerifyChain {
GTlsCertificate *chain;
+ gchar *purpose;
GSocketConnectable *identity;
GTlsDatabaseVerifyFlags flags;
GTlsCertificateFlags verify_result;
@@ -48,6 +49,7 @@ async_verify_chain_free (gpointer data)
{
AsyncVerifyChain *args = data;
g_object_unref (args->chain);
+ g_free (args->purpose);
if (args->identity)
g_object_unref (args->identity);
g_slice_free (AsyncVerifyChain, args);
@@ -63,6 +65,7 @@ async_verify_chain_thread (GSimpleAsyncResult *res,
args->verify_result = g_tls_database_verify_chain (G_TLS_DATABASE (object),
args->chain,
+ args->purpose,
args->identity,
args->flags,
cancellable,
@@ -75,6 +78,7 @@ async_verify_chain_thread (GSimpleAsyncResult *res,
static void
g_tls_database_real_verify_chain_async (GTlsDatabase *self,
GTlsCertificate *chain,
+ const gchar *purpose,
GSocketConnectable *identity,
GTlsDatabaseVerifyFlags flags,
GCancellable *cancellable,
@@ -86,10 +90,12 @@ g_tls_database_real_verify_chain_async (GTlsDatabase *self,
g_return_if_fail (callback);
g_return_if_fail (G_IS_TLS_CERTIFICATE (chain));
+ g_return_if_fail (purpose);
g_return_if_fail (!identity || G_IS_SOCKET_CONNECTABLE (identity));
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->flags = flags;
@@ -215,6 +221,7 @@ g_tls_database_class_init (GTlsDatabaseClass *klass)
GTlsCertificateFlags
g_tls_database_verify_chain (GTlsDatabase *self,
GTlsCertificate *chain,
+ const gchar *purpose,
GSocketConnectable *identity,
GTlsDatabaseVerifyFlags flags,
GCancellable *cancellable,
@@ -225,6 +232,7 @@ g_tls_database_verify_chain (GTlsDatabase *self,
G_TLS_CERTIFICATE_GENERIC_ERROR);
return G_TLS_DATABASE_GET_CLASS (self)->verify_chain (self,
chain,
+ purpose,
identity,
flags,
cancellable,
@@ -234,6 +242,7 @@ g_tls_database_verify_chain (GTlsDatabase *self,
void
g_tls_database_verify_chain_async (GTlsDatabase *self,
GTlsCertificate *chain,
+ const gchar *purpose,
GSocketConnectable *identity,
GTlsDatabaseVerifyFlags flags,
GCancellable *cancellable,
@@ -244,6 +253,7 @@ g_tls_database_verify_chain_async (GTlsDatabase *self,
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,
flags,
cancellable,
diff --git a/gio/gtlsdatabase.h b/gio/gtlsdatabase.h
index 4329aff..3bda975 100644
--- a/gio/gtlsdatabase.h
+++ b/gio/gtlsdatabase.h
@@ -35,6 +35,9 @@ typedef enum {
G_TLS_DATABASE_VERIFY_NONE = 0,
} GTlsDatabaseVerifyFlags;
+#define G_TLS_DATABASE_PURPOSE_SERVER_AUTH "1.3.6.1.5.5.7.3.1"
+#define G_TLS_DATABASE_PURPOSE_CLIENT_AUTH "1.3.6.1.5.5.7.3.2"
+
#define G_TYPE_TLS_DATABASE (g_tls_certificate_get_type ())
#define G_TLS_DATABASE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_DATABASE, GTlsDatabase))
#define G_TLS_DATABASE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_DATABASE, GTlsDatabaseClass))
@@ -58,6 +61,7 @@ struct _GTlsDatabaseClass
GTlsCertificateFlags (*verify_chain) (GTlsDatabase *self,
GTlsCertificate *chain,
+ const gchar *purpose,
GSocketConnectable *identity,
GTlsDatabaseVerifyFlags flags,
GCancellable *cancellable,
@@ -65,6 +69,7 @@ struct _GTlsDatabaseClass
void (*verify_chain_async) (GTlsDatabase *self,
GTlsCertificate *chain,
+ const gchar *purpose,
GSocketConnectable *identity,
GTlsDatabaseVerifyFlags flags,
GCancellable *cancellable,
@@ -99,6 +104,7 @@ GType g_tls_database_get_type (void) G_GNUC_CONST;
GTlsCertificateFlags g_tls_database_verify_chain (GTlsDatabase *self,
GTlsCertificate *chain,
+ const gchar *purpose,
GSocketConnectable *identity,
GTlsDatabaseVerifyFlags flags,
GCancellable *cancellable,
@@ -106,6 +112,7 @@ GTlsCertificateFlags g_tls_database_verify_chain (GTlsDatabase
void g_tls_database_verify_chain_async (GTlsDatabase *self,
GTlsCertificate *chain,
+ const gchar *purpose,
GSocketConnectable *identity,
GTlsDatabaseVerifyFlags flags,
GCancellable *cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]