Re: How To Access Public Key Certificate

From: Michel Gallant (neutron_at_NOSPAMistar.ca)
Date: 01/11/04


Date: Sun, 11 Jan 2004 11:32:40 -0500

The CERT_KEY_PROV_INFO_PROP_ID is only available for a certificate
contained in a certificate store AND having an associated private key.
In fact, you can test any cert for an associated private key using:
if (CertGetCertificateContextProperty(hCertCntxt, CERT_KEY_PROV_INFO_PROP_ID, ....

Typically, certs in the AddressBook store are certs received from others
(which of course you would/should NOT possess the corresponding private key).

Cheers,
 - Mitch Gallant

"Richard Grossman" <richard@goldmail.net.il> wrote in message
news:%23$k6%23KD2DHA.2700@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> I 've try the code as you've sugested.
> I can't even access CERT_KEY_PROV_INFO_PROP_ID by using the function
> if(!(CertGetCertificateContextProperty(
> pCertContext,
> CERT_KEY_PROV_INFO_PROP_ID,
> NULL, &dwSize)))
> {
> MyHandleError("Error getting key property.");
> }
>
> Why I can only access the above properties in my public certificate:
> Value returned by the function CertEnumCertificateContextProperties:
> CERT_MD5_HASH_PROP_ID,
> CERT_SHA1_HASH_PROP_ID,
> And CERT_KEY_IDENTIFIER_PROP_ID.
>
> And can't get other properties like : CERT_KEY_PROV_INFO_PROP_ID
>
> The certificate own only a public key and stored in the AdressBook
> certificate store.
>
> Please help. I'm really stuck with assymetric encryption. Is there anybody
> doing here asymetric encryption without enveloped data ??
>
>
>
>
>
> "David Miller [MSFT]" <dmiller@online.microsoft.com> wrote in message
> news:08A1AC57-AFE6-472D-ADCC-E9A4C0C8F809@microsoft.com...
> > Richard,
> >
> > You may want to review the code example at
>
http://msdn.microsoft.com/library/en-us/security/security/example_c_program_using_cryptencryptmessage_and_cryptdecryptmessage.asp
> for an example of encrypting a message using the public key of the
> recipient. As the comments suggest, it is likely you would want to extend
> the functionality of GetRecipientCert() to search for the specific
> recipient's certificate, but this may get you started.
> >
> > Thanks,
> > David
> >
> > This posting is provided "As Is" with no warranties, and confers no
> rights.
> > Use of included script samples are subject to the terms specified at
> > http://www.microsoft.com/info/cpyright.htm
> >
> >
> >
> > ----- Richard Grossman wrote: -----
> >
> > Hi,
> >
> > I want to implement PKI in a program.
> > I use only default key container of windows I mean "My", "AdressBook"
> To
> > store certificate.
> >
> > As I've understand (may be I wrong) "My" store certificate with
> private
> > key. Store AdressBook store public certificate (without private key).
> >
> > I'm trying to encrypt (asymetric a short message) using the public
> key
> > of a certifcate stored. I've tried to use the function
> > CryptAcquireCertificatePrivateKey but It can't aquire context for
> > certificate without private key associated.
> >
> > How can I aquire context or wich function I can call to get access to
> > the handle of public key certificate?
> >
> > Thanks for help
> >
> > Richard
> >
> >
>
>



Relevant Pages

  • Re: X509 Cert Services Cert
    ... oddest thing is that my Versign certs seem to work fine (with certificate ... for some reason cert service certs don't work for me. ... Ensure that the web service will have access to its private key in the ... > pressing Add, typing ASPNET, and then pressing OK. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • 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)