(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:
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:
Statement. Copyright 2000-2011 Chilkat
Software, Inc. All rights reserved.
Send feedback to firstname.lastname@example.org Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.