C Generate Plain Key Exportable Certificate

Hi all,


The other day a colleague of mine asked me if I had a .NETversion of the C++ sample in How to generate key pairs, encrypt and decrypt data with CryptoAPI post. C++ sample calls CryptoAPI directly (and you know we can do the same thing in .NET through P/Invoke), but the idea was to use System.Security classes in order to get a pure .NET solution. The answer is yes, I have such sample, and here it is:

If you really need the pfx, you will need to find a way to export the secret key from the device, and use openssl (or xca) to combine that with your cert to form a pfx - or generate the CSR yourself (xca, for example, can create a 'template' from an existing cert, and create a self signed or CA-signed certificate (or csr) from that using a. Nov 16, 2009  Hi, We have two SA-4500 in two different Data-Center with different IP addressing. But we're loadbalencing with the same public URL. I dont know how to export the private key from our primary SA to be able to upload our public certificate on the second SA.


If you compare both samples you will see that .NET simplifies the task a lot. But sometimes we won't be able to do with System.Security classes exactly the same we can do with CryptoAPI. So don't forget about the API just yet!

  1. “Bad key” exception for certificates with exportable private key. Ask Question Asked 10 years. With exportable private key. The certificates has been successfully created and installed, I see the 'You have a private key that corresponds to this certificate' note in mmc. How to create a self-signed certificate with OpenSSL.
  2. Import and Export Certificate - Microsoft Windows. Importing and Exporting an SSL Certificate in Microsoft Windows Article Purpose: This article provides step-by-step instructions for importing and exporting your SSL certificate in Microsoft Windows.If this is not the solution you are looking for, please search for your solution in the search bar above.

I hope this helps.


Kind regards,



/auto-generated-primary-key-in-oracle.html. Alex (Alejandro Campos Magencio)

How to Export a Certificate and PrivateKey in PKCS #12 Format

You can create a file in PKCS #12 format to export private keysand their associated X.509 certificate to other systems. Access to the fileis protected by a password.

  1. Find the certificate to export.


  2. Export the keys and certificate.

    Use the keystoreand label from the pktool list command. Provide a filename for the export file. When the name contains a space, surround the namewith double quotes.


  3. Protect the export file with a password.

    At the prompt,type the current password for the keystore. At this point, you create a passwordfor the export file. The receiver must provide this password when importingthe file.


    Tip –

    Send the password separately from the export file. Best practicesuggests that you provide the password out of band, such as during a telephonecall.

Example 15–4 Exporting a Certificate and Private Key in PKCS #12 Format

In thefollowing example, a user exports the private keys with their associated X.509certificate into a standard PKCS #12 file. This file can be importedinto other keystores. The PKCS #11 password protects the source keystore.The PKCS #12 password is used to protect private data in the PKCS #12file. This password is required to import the file.


Private Key Certificate Export


C Generate Plain Key Exportable Certificate Download

Php generate unique session key. The user then telephones the recipient and provides the PKCS #12 password.