Using CAPICOM to sign Data in C++



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++;
}
.



Relevant Pages

  • RE: SIMple SSL question ??
    ... I believe your book is instructing you to keep the private key secure. ... you use the certificate request wizard in IIS to install the cert after it's ... the certificate that's just been installed. ... If an attacker retrievs the SSL certificate, ...
    (microsoft.public.dotnet.security)
  • RE: SIMple SSL question ??
    ... I believe your book is instructing you to keep the private key secure. ... you use the certificate request wizard in IIS to install the cert after it's ... the certificate that's just been installed. ... If an attacker retrievs the SSL certificate, ...
    (microsoft.public.dotnet.security)
  • Re: Certificates, Keys, Mobile Users, Intended Usage
    ... Option that you think about uses self signed EFS certificates. ... Better then exporting user's private key as backup is to setup DRA (Data ... there is no EFS certificate and it will generate a new one. ... Mobile computer users benefit from encrypting sensitive ...
    (microsoft.public.win2000.security)
  • Re: PFXExportCertStoreEx
    ... which contains the actual PFX and write that to the disk. ... methods to export certificate + private key from the IE store. ...
    (microsoft.public.platformsdk.security)
  • Re: EFS On Drive Works With >1 Computer?
    ... >I just went to Help and Support Center to see if it says anything. ... > agent's private key and certificate, ... > certificate, decrypting the file or folder, and then deleting the imported ... Try to decrypt it on a computer that is not and has ...
    (microsoft.public.windowsxp.security_admin)