Sets the TLS private key file, certificate file, and the private key password.

C Language

int mqtt_set_tls_certificate( MQTT handle, const char* certificatePath, const char* pkeyPath, const char* pkeyPassword);

ExampleMQTT Vuser Functions


handleThe MQTT client handle returned by mqtt_create.
certificatePathThe path of the certificate file. The path can be absolute or relative to the script directory.
pkeyPasswordThe private key password. Pass MQTT_NONE if the private key is not encrypted.
pkeyPathThe path of the private key file. MQTT_NONE if certificate and private key are in the same file.


mqtt_set_tls_certificate sets the TLS private key file, certificate file, and the private key password. The files must be in PEM format. Call this function before mqtt_connect.

If invalid arguments are passed, the Vuser aborts, even if Continue on error is set.

Return Values



Standard parameterization is available for this function.

Exception: pkeyPassword cannot be parametrized (to avoid exposing in the output log)


MQTT client = mqtt_create();

/* Set TLS certificate for secured connection:

- client certificate file

- client private key file

- client private key password (encrypted in this case)

As file paths are relative, they are expected to be placed in the script directory and added as Extra Files


mqtt_set_tls_certificate(client, "client.crt", "client.key", lr_unmask("582c4f507db5f3df86f88518"));

mqtt_connect(client, "ssl://");