[gnome-keyring: 2/3] gcr: Display otherName subject-alt-name for xmppAddr and DNS SRV



commit 2ef650d1fa43fad0dc560533acc04a6c13175570
Author: Stef Walter <stefw collabora co uk>
Date:   Wed Aug 3 15:11:54 2011 +0200

    gcr: Display otherName subject-alt-name for xmppAddr and DNS SRV
    
     * Display the xmppAddr and DNS SRV otherName type subject alt names
       correctly. These are displayed as simple strings.
     * Also fix the critical warning when these were encountered.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=655902

 gcr/gcr-certificate-extensions.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/gcr/gcr-certificate-extensions.c b/gcr/gcr-certificate-extensions.c
index 97447e1..8256da2 100644
--- a/gcr/gcr-certificate-extensions.c
+++ b/gcr/gcr-certificate-extensions.c
@@ -132,8 +132,31 @@ _gcr_certificate_extension_key_usage (gconstpointer data, gsize n_data,
 static void
 general_name_parse_other (GNode *node, GcrGeneralName *general)
 {
+	GNode *decode = NULL;
+	GQuark oid;
+	gconstpointer value;
+	gsize n_value;
+
 	general->type = GCR_GENERAL_NAME_OTHER;
 	general->description = _("Other Name");
+
+	oid = egg_asn1x_get_oid_as_quark (egg_asn1x_node (node, "type-id", NULL));
+	value = egg_asn1x_get_raw_element (egg_asn1x_node (node, "value", NULL), &n_value);
+
+	if (value == NULL)
+		return;
+
+	if (oid == GCR_OID_ALT_NAME_XMPP_ADDR) {
+		general->description = _("XMPP Addr");
+		decode = egg_asn1x_create_and_decode (pkix_asn1_tab, "UTF8String", value, n_value);
+		general->display = egg_asn1x_get_string_as_utf8 (decode, g_realloc);
+	} else if (oid == GCR_OID_ALT_NAME_DNS_SRV) {
+		general->description = _("DNS SRV");
+		decode = egg_asn1x_create_and_decode (pkix_asn1_tab, "IA5String", value, n_value);
+		general->display = egg_asn1x_get_string_as_utf8 (decode, g_realloc);
+	}
+
+	egg_asn1x_destroy (decode);
 }
 
 static void
@@ -253,7 +276,7 @@ _gcr_certificate_extension_subject_alt_name (gconstpointer data, gsize n_data)
 		else if (g_str_equal (node_name, "registeredID"))
 			general_name_parse_registered (choice, &general);
 
-		general.raw = egg_asn1x_get_raw_value (choice, &general.n_raw);
+		general.raw = egg_asn1x_get_raw_element (choice, &general.n_raw);
 		g_array_append_val (names, general);
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]