|
|
|
@ -274,19 +274,23 @@ namespace suisseid { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Certificate certificate(const std::string& keylabel) { |
|
|
|
|
CRYPTOLOG("get certificate for key "<<keylabel); |
|
|
|
|
cryptoki::ObjectList keys // find keys with digsig-label
|
|
|
|
|
(session().find(cryptoki::AttributeList() |
|
|
|
|
<<cryptoki::Attribute(CKA_CLASS) |
|
|
|
|
.from<CK_OBJECT_CLASS>(CKO_PUBLIC_KEY) |
|
|
|
|
<<cryptoki::Attribute(CKA_LABEL, keylabel))); |
|
|
|
|
CRYPTOLOG("found "<<keys.size()<<" keys"); |
|
|
|
|
for (cryptoki::ObjectList::iterator key(keys.begin()); |
|
|
|
|
key!=keys.end(); ++key) { |
|
|
|
|
cryptoki::Attribute id(key->attribute(CKA_ID)); |
|
|
|
|
CRYPTOLOG("get certs for key with id "<<id); |
|
|
|
|
cryptoki::ObjectList certs |
|
|
|
|
(session().find(cryptoki::AttributeList() |
|
|
|
|
<<cryptoki::Attribute(CKA_CLASS) |
|
|
|
|
.from<CK_OBJECT_CLASS>(CKO_CERTIFICATE) |
|
|
|
|
<<id)); |
|
|
|
|
CRYPTOLOG("found "<<certs.size()<<" certificates"); |
|
|
|
|
for (cryptoki::ObjectList::iterator cert(certs.begin()); |
|
|
|
|
cert!=certs.end(); ++cert) { // return first matching cert
|
|
|
|
|
return Certificate(cert->attribute(CKA_VALUE).value, |
|
|
|
|