Home Contents | # pki:privateKey() | Cipher/PKI | Core4 Lua Commands

## SYNOPSIS

1. data = pki:privateKey([format])
2. data = pki:publicKey([format])
3. result = pki:savePrivateKey(filename[, format])
4. result = pki:savePublicKey(filename[, format])

## DESCRIPTION

This is a set of function to retrieve a stored key. The first two forms return the data as a Lua string variable, the second two forms save the key to a file.

The supported formats are "PEM" or "DER", the default is "PEM".

## RETURN VALUE

On success, the first two forms return a string, the second two forms write a file and return true.

In case of an error returns three values: nil, a string describing the error and a negative error code from the underlying mbed TLS implementation.

## SEE ALSO

pki:loadKeyData(), pki:loadKeyFile(), pki:loadPublicKeyData(), pki:loadPublicKeyFile(), pki:setKey()