Home  Contents

ssl:loadKeyData

Cipher/SSL Core4 Lua Commands

SYNOPSIS

  1. ok, err, errcode = ssl:loadKeyData(data)
  2. ok, err, errcode = ssl:loadKeyFile(filename)

DESCRIPTION

The private key pair is used together with a local certificate for proper authentication.

The key must be kept secure and must never become public, as this compromises security.

The system can load a RSA key in X509 PEM or BER format. DSA keys are not supported.

For web applications, typically only servers use a local certificate and private key.

The function ssl:loadKeyData() loads the certificate from the data passed in a string variable.

The second function, ssl:loadKeyFile() instead loads the certificate directly from a file.

It is recommended to always load the key directly from a file. If it is passed through a lua string, the private key may linger in memory until Lua does a garbage collection and reuses the memory. This makes the key prone to hacking attempts.

Note that for security reasons, there is no function to read back the key.

RETURN VALUE

The loading functions return true on success.

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

SEE ALSO