Share this page

# mqtt_set_tls_parameters

Sets the TLS version and cipher list for a connection.

## C Language

int mqtt_set_tls_parameters( MQTT handle, enum MQTT_TLS_VERSION version, const char* ciphers);

MQTT Vuser Functions

## Arguments

Name | Comments
--- | ---
handle | The MQTT client handle returned by mqtt_create.
version | The TLS protocol version. An element of the MQTT_TLS_VERSION enum. One of: MQTT_TLS_DEFAULT - Value from runtime settings MQTT_TLS1 MQTT_TLS11 MQTT_TLS12
ciphers | The list of ciphers to use. Specify one of the following: MQTT_DEFAULT_CIPHERS - Uses the default value, ALL. A colon-separated list of values from ciphers(1) - Linux man page in the Linux online documentation.

## General Information

mqtt_set_tls_parameters sets the TLS version and cipher list for a connection. Call this function before mqtt_connect.

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

## Return Values

MQTT_SUCCESS or MQTT_FAIL

## Parameterization

Standard parameterization is not available for this function.

## Example

vuser_init()

{

/* Declared in "globals.h" */

client = mqtt_create();

/* Optional connection settings */

mqtt_set_client_id(client, lr_eval_string("perfcore-{vuid}"));

mqtt_set_credentials(client, "qatest1", lr_unmask("5811bce9842ef303f4d8"));

// mqtt_set_lwt(client, "<topic>", "<sample lwt payload>", MQTT_AUTO, MQTT_DEFAULT);

/* Optional SSL/TLS settings, applicable for SSL/TLS connections only */

// mqtt_set_tls_certificate(client, "<path to a certificate file, e.g. cert.pem>", "<path to a private key file, e.g. key.pem>", "<password to the private key>");

// mqtt_set_tls_parameters(client, MQTT_DEFAULT, MQTT_DEFAULT_CIPHERS);

/* Connect to an MQTT broker */

mqtt_connect(client, "tcp://myserver:1883");

/* Uncomment the following in case of implementing the "subscriber" logic */

mqtt_subscribe(client, "users/qatest1/demo");

return 0;

}

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: