Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

December 4, 2007

(from PFX) How to Extract Public/Private Keys and Certs into String Variables

The Chilkat customer’s question that prompted this example is: "How do I extract keys and certificates from a PFX so that I can store them as strings in a relational database? I would like to later read a certificate and key (public or private) to use it for encryption, decryption, signature creation or signature verification."

Note: When only the public key is needed, it shouldn’t be necessary to save the public key apart from the certificate. The certificate itself includes the public key material required for signature verification and encryption.

These examples show how to extract public/private keys and certs into string variables:

ASP: Extract Public/Private Keys and Certs from PFX into String Variables
SQL Server: Extract Public/Private Keys and Certs from PFX into String Variables
C#: Extract Public/Private Keys and Certs from PFX into String Variables
C++: Extract Public/Private Keys and Certs from PFX into String Variables
Delphi: Extract Public/Private Keys and Certs from PFX into String Variables
Visual FoxPro: Extract Public/Private Keys and Certs from PFX into String Variables
Java: Extract Public/Private Keys and Certs from PFX into String Variables
Perl: Extract Public/Private Keys and Certs from PFX into String Variables
Python: Extract Public/Private Keys and Certs from PFX into String Variables
Ruby: Extract Public/Private Keys and Certs from PFX into String Variables
VB.NET: Extract Public/Private Keys and Certs from PFX into String Variables
Visual Basic: Extract Public/Private Keys and Certs from PFX into String Variables
VBScript: Extract Public/Private Keys and Certs from PFX into String Variables

Once you have the key or cert in a string, it’s up to you to store it in the DB….

To use the private key + cert, query the DB to retrieve the strings, and load them back into the Chilkat objects (this is demonstrated in the examples above.)

To use the private key, you must first create or open a KeyContainer, import the private key into it, and then link the cert to the private key. This example shows how to do it for the purpose of creating a digital signature:

ASP: Use Certificate and Private Key PEM Files to Create a Digital Signature
C#: Use Certificate and Private Key PEM Files to Create a Digital Signature
C++: Use Certificate and Private Key PEM Files to Create a Digital Signature
Delphi: Use Certificate and Private Key PEM Files to Create a Digital Signature
Visual FoxPro: Use Certificate and Private Key PEM Files to Create a Digital Signature
Java: Use Certificate and Private Key PEM Files to Create a Digital Signature
Perl: Use Certificate and Private Key PEM Files to Create a Digital Signature
Python: Use Certificate and Private Key PEM Files to Create a Digital Signature
Ruby: Use Certificate and Private Key PEM Files to Create a Digital Signature
VB.NET: Use Certificate and Private Key PEM Files to Create a Digital Signature
Visual Basic: Use Certificate and Private Key PEM Files to Create a Digital Signature
VBScript: Use Certificate and Private Key PEM Files to Create a Digital Signature


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.