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