Back to product page

GenerateKey method


Generates new private key.

Type

None

Syntax

  • Basic
object.GenerateKey [KeyType]
The GenerateKey(object,KeyType) syntax has these parts:
objectAn expression evaluating to an object of type Certificate.
KeyTypeA Variant value. Determines type of the key (RSA or DSA), as listed in CertKeyTypes enumeration.

Remarks

GenerateKey method should be called when you need to generate new key. Old key (loaded in memory) will be destroyed, and new one will take its place. It is advised that immediately after new key is generated, you should Save it to a file for future use. This method will also clear out all information about the certificate, so if you prepared information for generating new certificate (such as setting CommonName, Country etc..) it will be destroyed. You should first GenerateKey, fill up necessary properties, then call Generate method.

GenerateKey method can be a lengthy process, especially if you set large BitCount value (default BitCount is 1024). It is advised that you make random mouse movements, or type on the keyboard during the key generation, to get more random values for new key.

If you wish to transfer your existing key from OpenSSH (or similar) SSH server, you can easily load such key using LoadKey method. In such case there is no need to generate new key.

Important thing is to keep the key private and unreadable by anyone else except yourself. To help you accomplish this, storing generated key can optionally be protected using a password in SaveKey method.

After key is generated, you can optionally generate new certificate using Generate method.

Platforms

Windows