summaryrefslogtreecommitdiff
path: root/ckcapi-key.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2008-12-08 20:19:37 +0000
committerStef Walter <stef@memberwebs.com>2008-12-08 20:19:37 +0000
commitc5412bd90d5f72aec7aa3131d3097642f297e7ba (patch)
tree20933c105b690057d91f4edac80cbd6a67b5a7df /ckcapi-key.c
parentd30c444305b4fcde74fb39b065a9f716540f9592 (diff)
Find key objects properly. Don't error when a certificate doesn't have a key object backing it.
Diffstat (limited to 'ckcapi-key.c')
-rw-r--r--ckcapi-key.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/ckcapi-key.c b/ckcapi-key.c
index 88e769e..d36a4c9 100644
--- a/ckcapi-key.c
+++ b/ckcapi-key.c
@@ -898,12 +898,18 @@ find_certificate_key(CkCapiSession* session, CK_OBJECT_CLASS cls,
KeyObjectData kdata;
CkCapiObject* obj;
DWORD prov_length;
- CK_RV ret;
+ DWORD error;
+ CK_RV ret = CKR_OK;
/* Look up the key provider info and identifier */
if(!CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, NULL, &prov_length) ||
!CertGetCertificateContextProperty(cert, CERT_KEY_IDENTIFIER_PROP_ID, NULL, &key_identifier.cbData))
- return ckcapi_winerr_to_ckr(GetLastError());
+ {
+ error = GetLastError();
+ if(error == CRYPT_E_NOT_FOUND)
+ return CKR_OK;
+ return ckcapi_winerr_to_ckr(error);
+ }
/* We own the info memory */
prov_info = malloc(prov_length);
@@ -949,6 +955,10 @@ find_certificate_key(CkCapiSession* session, CK_OBJECT_CLASS cls,
}
}
}
+ else
+ {
+ ret = ckcapi_winerr_to_ckr(GetLastError());
+ }
if(key_identifier.pbData)
free(key_identifier.pbData);