Home  Contents

httpd:loadKeyData

Httpd Core4 Lua Event System

SYNOPSIS

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

DESCRIPTION

This setting is necessary when using SSL/TLS with the built-in webserver.

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.

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

The second function, httpd: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.

RETURN VALUE

Returns 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