OpenSC wrote:
#68: pkcs15-tool -L fails: Unable to cache file: Invalid arguments
-------------------------------------------+--------------------------------
Id: 68 | Status: new Component: tools | Modified: Sat Jan 21 18:31:22 2006 Severity: normal | Milestone: Priority: normal | Version: 0.10.1 Owner: opensc-devel@lists.opensc.org | Reporter: [EMAIL PROTECTED] -------------------------------------------+--------------------------------
 I am not able to cache certificates on my STARCOS SPK 2.3 / TC StarSign
 card.
...
 With a bit of debugging I think I found the culprit:
 The check
 {{{
          if (path->type != SC_PATH_TYPE_PATH)
                 return SC_ERROR_INVALID_ARGUMENTS;
 }}}
 in function generate_cache_filename()
 at lines 44 & 45 in file src/libopensc/pkcs15-cache.c
 seems to be wrong (at least with STARCOS SPK3 cards).

I think the problem is that the token doesn't absolute paths
when specific the path to the certificate. The above check in
generate_cache_filename() makes sense as we can't really cache
a file when we only have a relative path.


 Removing these two lines, recompiling libopensc.so
 and LD_PRELOADING the compiled version of the library
 allows the otherwise unchanged pkcs15-tool to successfully
 cache the card's certificates.

could you please test if the attached patch helps ?

Cheers,
Nils
Index: src/tools/pkcs15-tool.c
===================================================================
--- src/tools/pkcs15-tool.c     (Revision 2857)
+++ src/tools/pkcs15-tool.c     (Arbeitskopie)
@@ -1140,10 +1140,20 @@
                read_and_cache_file(&df->path);
        printf("Caching %d certificate(s)...\n", cert_count);
        for (i = 0; i < cert_count; i++) {
+               sc_path_t tpath;
                struct sc_pkcs15_cert_info *cinfo = (struct sc_pkcs15_cert_info 
*) certs[i]->data;
                
                printf("[%s]\n", certs[i]->label);
-               read_and_cache_file(&cinfo->path);
+
+               tpath = cinfo->path;
+               if (tpath.type == SC_PATH_TYPE_FILE_ID) {
+                       /* preprend application DF path in case of a file id */
+                       r = sc_concatenate_path(&tpath, 
&p15card->file_app->path, &tpath);
+                       if (r != SC_SUCCESS)
+                               return r;
+               }
+
+               read_and_cache_file(&tpath);
        }
 
        return 0;
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to