Description
-
Loads a private key from an external file.
Return type
-
A Long value. If successful, 0 is returned, otherwise
error as specified here.
Syntax
-
long Sftp_LoadPrivateKey(void *Sftp, char
*Filename, char *Password);
The LoadPrivateKey function syntax has these parts:
| void
*Sftp |
Handle of the created Sftp
instance. |
| char
*Filename |
Name of the file that
holds the private key. |
| char
*Password |
Optional password
needed to open private key (NULL or "" for
optional). |
Remarks
-
Unlike the ActiveX version of wodSSH, that comes with its own keys component to simplify key management,
the library version has no such function.
For this reason, from version 1.0.2.0, we have included the
LoadPrivateKey function that can load keys stored in PEM
format. They should look like this:
- -----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 generated describing
the error. The most common error that will
occur when loading a key is if the password does not match the one that was used when the key
was saved.
-
-
Besides opening keys in PEM format, this function will also try to open Putty
generated keys, as well as Vandyke and SSH1 RSA private keys. Also, it
will try to open PFX files (PKCS#12 format) and try to find any
private keys that they contain.
|