Home  Contents

pki:loadKeyData()

Cipher/PKI Core4 Lua Commands

SYNOPSIS

  1. result = pki:loadKeyData(data[, password])
  2. result = pki:loadKeyFile(filename[, password])
  3. result = pki:loadPublicKeyData(data)
  4. result = pki:loadPublicKeyFile(filename)

DESCRIPTION

This is a set of function to load a stored key. The first two forms load a private key from a string or file, the second two forms load just a public key from file or string.

Loading a new key discards any previous key that was stored in the object.

When loading from a file, then the supported formats are "PEM" or "DER". The format is automatically detected.

When loading from a string, the key must be in binary DER format. This seems to be a mbedTLS issue, the documentation of mbedtls_pk_parse_key() claims PEM is fine, too.

Specifying a password is only required if the key is password protected.

RETURN VALUE

On success, returns 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