]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
When listing all objects of a type, restrict their class to the specified.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 12 Nov 2012 17:24:04 +0000 (18:24 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 12 Nov 2012 17:24:08 +0000 (18:24 +0100)
lib/pkcs11.c

index 73744cff1b24ad094a7b614224310eeb5c9ad437..a4b7728b1646cbaa740bcf2ce4f44ba85a8e7f7b 100644 (file)
@@ -1491,7 +1491,6 @@ find_obj_url (struct pkcs11_session_info *sinfo,
 
   while (pkcs11_find_objects (sinfo->module, sinfo->pks, &obj, 1, &count) == CKR_OK && count == 1)
     {
-
       a[0].type = CKA_VALUE;
       a[0].value = cert_data;
       a[0].value_len = MAX_CERT_SIZE;
@@ -2262,6 +2261,16 @@ find_objs (struct pkcs11_session_info* sinfo,
         }
     }
 
+  /* Find objects with given class and type */
+  attr = p11_kit_uri_get_attribute (find_data->info, CKA_CLASS);
+  if (attr)
+    {
+      if(attr->value && attr->value_len == sizeof (ck_object_class_t))
+        class = *((ck_object_class_t*)attr->value);
+      if (class == CKO_CERTIFICATE)
+        type = CKC_X_509;
+    }
+
   cert_data = gnutls_malloc (MAX_CERT_SIZE);
   if (cert_data == NULL)
     {