From: Petr P. <pet...@at...> - 2013-08-30 14:46:03
|
Previously, it was not possible to load a certificate by a label because it alwayes searched by undefined ID value. This has been fixed to behave in the same way as searching for a key. --- src/engine_pkcs11.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/engine_pkcs11.c b/src/engine_pkcs11.c index 42d90e2..34b65d6 100644 --- a/src/engine_pkcs11.c +++ b/src/engine_pkcs11.c @@ -497,13 +497,19 @@ static X509 *pkcs11_load_cert(ENGINE * e, const char *s_slot_cert_id) fprintf(stderr, "Found %u cert%s:\n", cert_count, (cert_count <= 1) ? "" : "s"); } - if ((s_slot_cert_id && *s_slot_cert_id) && (cert_id_len != 0)) { + if ((s_slot_cert_id && *s_slot_cert_id) && (cert_id_len != 0 || cert_label != NULL)) { for (n = 0; n < cert_count; n++) { PKCS11_CERT *k = certs + n; - if (cert_id_len != 0 && k->id_len == cert_id_len && - memcmp(k->id, cert_id, cert_id_len) == 0) { - selected_cert = k; + if (cert_label == NULL) { + if (cert_id_len != 0 && k->id_len == cert_id_len && + memcmp(k->id, cert_id, cert_id_len) == 0) { + selected_cert = k; + } + } else { + if (strcmp(k->label, cert_label) == 0) { + selected_cert = k; + } } } } else { -- 1.8.1.5 |