CAPICOM sign file directly using spc store and pkv private key file



is there a way to:assign in CAPICOM Signer object a certificate and private
key?

ok I open a certificate store, actually - create one and load certificates
fom file

hr =
ptrStore->Open(CAPICOM::CAPICOM_CURRENT_USER_STORE,"MyStorage",CAPICOM::CAPICOM_STORE_OPEN_READ_WRITE);
hr =
ptrStore->Load(bstrSPCFile,bstrPassword,CAPICOM::CAPICOM_KEY_STORAGE_USER_PROTECTED);

then select my certificate

ptrCertificates = ptrStore->Certificates;
ptrCertificate = (CAPICOM::ICertificate2Ptr)ptrCertificates->GetItem(1);

then assign my certificate to the signer object, build chain

ptrSigner->Certificate = ptrCertificate;
ptrSigner->Chain->Build(ptrCertificate);

Now I want to load private key from pvk and assign it to selected
certificate.
CAPICOM::IPrivateKeyPtr ptrPrivateKey;
hr = ptrPrivateKey.CreateInstance( __uuidof( CAPICOM::PrivateKey ) );

// or yes I do this also later
// associate private key
ptrCertificate->PrivateKey = ptrPrivateKey;

Assuming I am sucessfull in parsing undocumented PVK file format, getting
the CRYPTOBLOB data
how do I fill in all data in ptrPrivateKey CAPICOM object? Or it is not
possible at all via CAPICOM?

Or am I on a wrong track here altogether? Any way to do this straight from
CryptoAPI, samples are welcomed since I am stuck on filling this PrivateKey
object step.

TECH
http://www.tversoft.com


.



Relevant Pages

  • HttpWebRequest client certificate private key problem (VB.NET 2002)
    ... I have a valid client certificate with a corresponding private key. ... certificate is in x509 format and the .cer file contains the private ... Q1- What kindof filedoes the CreateFromSignedFile accept? ...
    (microsoft.public.dotnet.security)
  • Re: Newbie: Getting my head around Certificates
    ... and does not ship with Windows. ... CAPICOM as part of your application. ... To retrieve the server SSL certificate used by IE, ... > .Display() method of the ICertificate2 interface. ...
    (microsoft.public.platformsdk.security)
  • Re: signing a hash thats been created outside Crypto-API
    ... > This automatically manages acquiring access to the private key contained ... Our requirement is that a user be able to specify a certificate ...
    (microsoft.public.platformsdk.security)
  • Re: "Access denied" on encrypted files after reinstall
    ... Possibly your private ... administrator account would be the recovery agent which is required in W2K. ... to decrypt them. ... the certificate that you can then try to match up to the certificate in the ...
    (microsoft.public.win2000.security)
  • Re: using .p12 and K509 in NET 1.1
    ... the easiest way to do this is to import the certificate via the ... P12 with the private key into the machine store. ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ...
    (microsoft.public.dotnet.framework.aspnet.security)