From 0ffad3f3bb9c893ab5a06998c7c7f0d571e7918d Mon Sep 17 00:00:00 2001 From: Robert Quattlebaum Date: Mon, 9 Feb 2015 02:13:37 -0800 Subject: [PATCH] Fix for bad caching behavior of PIV PKCS15 emulator. --- src/libopensc/pkcs15-piv.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libopensc/pkcs15-piv.c b/src/libopensc/pkcs15-piv.c index 7f465987..724987bd 100644 --- a/src/libopensc/pkcs15-piv.c +++ b/src/libopensc/pkcs15-piv.c @@ -735,11 +735,13 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card) ckis[i].cert_found = 1; /* cache it using the PKCS15 emulation objects */ /* as it does not change */ - if (cert_der.value) { - cert_info.value.value = cert_der.value; - cert_info.value.len = cert_der.len; - cert_info.path.len = 0; /* use in mem cert from now on */ - } + if (cert_der.value) { + cert_info.value.value = cert_der.value; + cert_info.value.len = cert_der.len; + if (!p15card->opts.use_file_cache) { + cert_info.path.len = 0; /* use in mem cert from now on */ + } + } /* following will find the cached cert in cert_info */ r = sc_pkcs15_read_certificate(p15card, &cert_info, &cert_out); if (r < 0 || cert_out->key == NULL) {