Hi,

I have created a certificate using Openssl. All works fine and I can encrypt and decrypt a file just using openssl from command prompt, so I know certificate is working ok.
I need to do the same programatically, but I am having problems.

When calling CertGetCertificateContextProperty() to obtain the CRYPT_KEY_PROV_INFO* structure, it fails with error code CRYPT_E_NO_KEY_PROPERTY.

I have got it to work using a Certificate I have in "my" store, but not with the onr in "root" created using openssl.

Any ideas?

Thanks

Code:
  DWORD dwSize = NULL;

      CRYPT_KEY_PROV_INFO* pCryptKeyProvInfo;

    

      //Get Length of data to be returned

if(!(CertGetCertificateContextProperty(pRecipientCert,CERT_KEY_PROV_INFO_PROP_ID, NULL, &dwSize)))

    {

            printf("The property length was not retrieved.");

    }

    if(!(pCryptKeyProvInfo = (CRYPT_KEY_PROV_INFO*) malloc(dwSize)))

    {

          printf("Error in allocation of memory.");

      }

      //call again with length & pointer to structure

      if(!(CertGetCertificateContextProperty(pRecipientCert, CERT_KEY_PROV_INFO_PROP_ID, pCryptKeyProvInfo, &dwSize))) 

      { 

           printf("Error getting key property."); 

      } 
    }