|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: jooandras
ibcnet.roDate: Tue Aug 21 2001 - 11:02:15 CDT
Hi all !
I'm not sure this is the rigth place to ask these kind of questions, but
I'll try. Maybe somebody can help me.
Some infos, about the problem:
Platform: Windows 2000
Programming language: Visual C++ 6
API: CryptoAPI
Smart Card & Reader: ActivCard Gold
Problem descrtiption: I have a personal certificate in the system tore
"MY", and I have to copy this certificate to the smart card. As I have
read in the MSDN there is a system certificate store called "UserDS"
planned to use with smart cards. But when I try to put the certificate
into this store, the program stops, with an Accesss denied error message.
Here is the code:
HCRYPTPROV csp_handle;
HCERTSTORE cert_store_handle;
HCERTSTORE another_cert_store_handle;
PCCERT_CONTEXT cert_context = NULL;
if (!CryptAcquireContext(&csp_handle,NULL,
get_installed_csp(0),PROV_RSA_FULL,0))
{
if
(!create_key_container(&csp_handle,"key_container",get_installed_csp(0)))
exit(1);
}
cert_store_handle = CertOpenSystemStore(csp_handle,"MY");
cert_context = CertEnumCertificatesInStore(cert_store_handle,
cert_context);
another_cert_store_handle =
CertOpenSystemStore(csp_handle,"UserDS");
//the program fails in the next line
if
(!CertAddCertificateContextToStore(another_cert_store_handle,cert_context,CERT_STORE_ADD_REPLACE_EXISTING,NULL))
{
write_error_message(GetLastError());
}
if (!CertFreeCertificateContext(cert_context)) exit(1);
if
(!CertCloseStore(another_cert_store_handle,CERT_CLOSE_STORE_FORCE_FLAG))
exit(1);
if
(!CertCloseStore(cert_store_handle,CERT_CLOSE_STORE_FORCE_FLAG)) exit(1);
if (!CryptReleaseContext(csp_handle,0)) exit(1);
Remarks:
The get_installed_csp() gets the i'th installed csp's name.
The create_key_container() creates a key container
The write_error_message() writes the error message which is attached to
the error code.
Any help is appreciated.
Thanks,
andras
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]