From 6274dd09e8d3dd1224efd20160731854aae98d13 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 3 Aug 2011 15:11:54 +0200 Subject: [PATCH] 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 file changed, 24 insertions(+), 1 deletion(-) 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); } -- 2.7.4