Using CAPICOM to sign Data in C++
- From: Kristoff P. <KristoffP@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 11 Jun 2009 22:24:01 -0700
Hey, I'm developing an application using C++ which will require me to select
a certificate from the MYSTORE and use its private key to sign some data. So
far I am able to retrieve a certificate from the certificate store, but I am
stuck. How do I access the certificate's private key and/or sign data with
the selected certificate's private key USING CAPICOM.DLL. There are a few
solutions using System.dll and system namespace and wincrypt, but I am
required to use CAPICOM namespace. Here is the code I have to open the
certificate store to display all the certificates (in a GUI) and when clicked
on the selected certificate to display it:
//load the keystore
CAPICOM::IStorePtr loadkeystore(){
_bstr_t bstrName = _T("My");
IStorePtr pIStore(__uuidof(Store));
if (FAILED(hr = pIStore->Open(CAPICOM_CURRENT_USER_STORE,
bstrName,
CAPICOM_STORE_OPEN_READ_ONLY)))
return pIStore;
}
//display the selected certificate
int num =0;
index = m_listCtrl.GetSelectionMark();
////m_listCtrl is a listBox in GUI where certificate properties are being
displayed
while (pIEnum->Next(1, &pDisp, &ulFetched) == S_OK)
{
if(num == index)
{
cert = (ICertificatePtr) pDisp.pdispVal;
cert->Display();
return;
}
num++;
}
.
- Prev by Date: Make process hard to delete for a non admin user
- Next by Date: Question and Problem about "csptestsuite.exe" result?!!
- Previous by thread: Make process hard to delete for a non admin user
- Next by thread: Question and Problem about "csptestsuite.exe" result?!!
- Index(es):
Relevant Pages
|