|
|
|
date: Wed, 23 Jul 2008 16:30:00 -0700,
group: microsoft.public.platformsdk.security
back
Problem exporting MY certificate store with private keys
Hi,
I have a problem exporting MY certificate store with private keys. There is
only one certificate on the store. Here is how certificate was created and
added to the store.
1. Create KeyProvInfo and acquire hCryptProv by calling CryptAcquireContext
with CRYPT_NEWKEYSET flag.
2. Generate keys by calling CryptGenKey with CRYPT_EXPORTABLE flag.
3. Create cetificate request using aquired hCryptProv.
4. Send certificate request to server and received *.cer data blob form it.
5. Create certificate context and add certificate to MY, CA and ROOT stores.
At this point I can see cetificate on the store but without private key
present.
6. Associate private key to the Certificate using
CertSetCertificateContextProperty( pCertCxt,CERT_KEY_PROV_INFO_PROP_ID, 0,
pKeyProvInfo)
7. Associate certificate to the key on the smart card (needed for EAP-TLS
authentication) using
CryptSetKeyParam(hCurKey,KP_CERTIFICATE,pCertCxt->pbCertEncoded, 0)). At
this point I can see certificate on the store with Private Key present.
8. Export MY store using PFXExportCertStoreEx with
dwFlags = (EXPORT_PRIVATE_KEYS | REPORT_NO_PRIVATE_KEY |
REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY). Function returns with an error 0x57
(The parameter is incorrect).
If I use dwFlags = 0, function returns without error, but store import
(PFXImportCertStore) later on results in certificate without private key.
What can cause PFXExportCertStoreEx to error when I try to export store with
private keys?
Thanks,
Anthony
date: Wed, 23 Jul 2008 16:30:00 -0700
author: Anthony
|
|