[libnma/lr/pkcs11-fixes: 12/12] cert-chooser-dialog: prefer CKA_LABEL to subject name
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libnma/lr/pkcs11-fixes: 12/12] cert-chooser-dialog: prefer CKA_LABEL to subject name
- Date: Mon, 21 Mar 2022 13:03:57 +0000 (UTC)
commit 62f3e873ce45eaf1f496e7667cd909ecdd28dda5
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Wed Jan 19 10:16:57 2022 +0100
cert-chooser-dialog: prefer CKA_LABEL to subject name
It seems to tend to be more meaningful.
src/nma-pkcs11-cert-chooser-dialog.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/nma-pkcs11-cert-chooser-dialog.c b/src/nma-pkcs11-cert-chooser-dialog.c
index 93500e88..2ec2ce1c 100644
--- a/src/nma-pkcs11-cert-chooser-dialog.c
+++ b/src/nma-pkcs11-cert-chooser-dialog.c
@@ -119,7 +119,8 @@ object_details (GObject *source_object, GAsyncResult *res, gpointer user_data)
CK_OBJECT_CLASS cka_class;
const GckAttribute *attr;
GcrCertificate *cert;
- gchar *label, *issuer;
+ gchar *label = NULL;
+ gchar *issuer = NULL;
GError *error = NULL;
GtkListStore *store1, *store2;
IdMatchData data;
@@ -157,24 +158,27 @@ object_details (GObject *source_object, GAsyncResult *res, gpointer user_data)
id_match,
&data);
+ attr = gck_attributes_find (attrs, CKA_LABEL);
+ if (attr && attr->value && attr->length) {
+ label = g_malloc (attr->length + 1);
+ memcpy (label, attr->value, attr->length);
+ label[attr->length] = '\0';
+ }
+
attr = gck_attributes_find (attrs, CKA_VALUE);
if (attr && attr->value && attr->length) {
cert = gcr_simple_certificate_new (attr->value, attr->length);
- label = gcr_certificate_get_subject_name (cert);
+ if (!label)
+ label = gcr_certificate_get_subject_name (cert);
issuer = gcr_certificate_get_issuer_name (cert);
g_object_unref (cert);
- } else {
- attr = gck_attributes_find (attrs, CKA_LABEL);
- if (attr && attr->value && attr->length) {
- label = g_malloc (attr->length + 1);
- memcpy (label, attr->value, attr->length);
- label[attr->length] = '\0';
- } else {
- label = g_strdup (_("(Unknown)"));
- }
- issuer = g_memdup ("", 1);
}
+ if (!label)
+ label = g_strdup (_("(Unknown)"));
+ if (!issuer)
+ issuer = g_memdup ("", 1);
+
gtk_list_store_append (store1, &iter);
gtk_list_store_set (store1, &iter,
COLUMN_LABEL, label,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]