Back to product page

Load method


Loads keys from the file.

Type

None

Syntax

  • Basic
object.Load Filename, [Password]
The Load(object,Filename,Password) syntax has these parts:
objectAn expression evaluating to an object of type Keys.
FilenameRequired. A String value. Full path to file where key is stored.
PasswordOptional. A Variant value. Secret password used to protect the key.

Remarks

Load method will try to load in memory previously saved key using Save method, or saved using external programs such as ssh-keygen included in OpenSSH package. File should be accessible and readable by yourself in the time when Load is requested.

If Load is successful, wodKeys will recognize key type (RSAkey, DSAkey or ECDSAkey) and overwrite old one from memory (if any). If you use more than one key, you should call Load method more than once, specifying different file in each call.

Saved key should be in PEM format. PEM format is simply base64 encoded data surrounded by header lines (this is the format that is used in Save method) and is widely supported by different SSH implementations. Load additionally transparently handle PKCS#8 format encrypted and unencrypted keys too. Typical structure looks like this (for RSAKey):

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CFB,33E78EDBC3F91072

bKxPNDjHoqW4wT46OnYnDWtJnhwhqRIh81o9IAjjrrlRRDQf9kefDFuciKBrJCqK
................................................................
                          (...more...)
................................................................
ViWBhtNOV1Wzm3Ifv9ekm6cd1TjPO2UP/Vi5/Xz4PQ+maA7c1QXbdXGF29fc2VFI
JQKZxKKEfirZntyOH6chDQGeYnB7mXLpRNnNb7g=
-----END RSA PRIVATE KEY-----


If loading fails, an error will be generating describing the error. Most common error when loading the key will occur if password does not match one that was used when key was saved.

Besides opening PEM format, Load method will try to open Putty, Vandyke, SSH1.0, SSH.COM and F-Secure generated keys. Also, it will try to open PFX files (PKCS#12 format) and try to find any private keys in that file. When saved, these keys will be saved in PEM format. You may need to remove passphrase from foreign keys when you try to import them with Load method!

Note: since version 1.1.2.9 Load method can accept also string representation of the key. This allows you to keep the key in your application, rather than external file. Only PEM format is supported this way. So, you can use code like this, it will work:

Dim key As WODSSHKeyLib.Keys
Dim KeyData As String
KeyData = "-----BEGIN RSA PRIVATE KEY-----" & vbCrLf & _
"MIICWgIBAAKBgQC3cmHl8c2qdVP3Vn7FBXB/U/D+P/HI0daomwIIxqxQp7f4gGbY" & vbCrLf & _
"IUt1cntQD1qa2qSmBDQC7ZL8Ihn11l+fwhrt4p/7H5YcimIyjM6gtAoU7TVWg+ji" & vbCrLf & _
....
"m9fDlSj9Eq75nzAcwt4/BmqmJ/8Ei2sLGHw/6HlW" & vbCrLf & _
"-----END RSA PRIVATE KEY-----"
Set key = New Keys
key.Load KeyData


Platforms

Windows