Open topic with navigation
int mqtt_set_tls_certificate( MQTT handle, const char* certificatePath, const char* pkeyPath, const char* pkeyPassword);
|Example||MQTT Vuser Functions|
|handle||The MQTT client handle returned by mqtt_create.|
|certificatePath||The path of the certificate file. The path can be absolute or relative to the script directory.|
|pkeyPassword||The private key password. Pass MQTT_NONE if the private key is not encrypted.|
|pkeyPath||The 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.
MQTT_SUCCESS or MQTT_FAIL
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"));