Saving an RSA key pair to a file

Question:

I’m having trouble finding a good/complete VB.Net Chilkat example of how to generate an RSA key container with a key pair (private and public) and save that key container to a file.

Answer:

I think I can clarify.  With 2 points:

1) In actuality, an RSA private key also contains the public-part of the key.  It contains the all of the key parts:  modulus, exponent, D, P, Q, DP, DQ, and InverseQ.  The public key is really just a sub-set of the private key and is composed of the modulus and exponent.  Therefore, to save the key pair, you really only need to save the private key.

2) The “key container” in a file would be an encrypted or unencrypted PEM (text) or DER (binary) file.  Either can be PCKS8 format or “RSA” format.  You would use the Chilkat.PrivateKey file to save the private key to PEM or DER (see the reference docs).  You may export the private key from the Chilkat.Rsa class to an XML string, and then load it into the Chilkat.PrivateKey class, and then save it to a file in whichever format you desire, using encryption or not.

Converting a PuTTY Private Key (.ppk) to OpenSSH (.pem)

ASP: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
SQL Server: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
C#: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
C++: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
MFC: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
C: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
Delphi: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
Visual FoxPro: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
Java: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
Perl: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
PHP: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
Python: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
Ruby: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
VB.NET: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
Visual Basic: Convert PuTTY Private Key (ppk) to OpenSSH (pem)
VBScript: Convert PuTTY Private Key (ppk) to OpenSSH (pem)

Private Key Warning Dialog

If your application is using a pre-installed certificate for creating a digital signature, or for decrypting, then it needs access to the private key. (By pre-installed, we mean a certificate that has been imported from a PFX (or via the browser) into a Windows registry-based certificate store.)

If you chose to enable strong private key protection, then the Windows operating system will display a warning dialog when any application attempts to access the private key. To disable this warning, you’ll need to re-install the certificate without strong private key protection.

This is what the warning dialog looks like:
Private Key Warning Dialog

When importing the PFX via the Certificate Management Console (cert.msc), do not check the checkbox to enable strong private key protection:
PFX Import