Merge pull request #2017 from fengzeroz/v2.4

V2.4
This commit is contained in:
fengzeroz
2024-05-23 15:50:29 +08:00
committed by GitHub
4 changed files with 10 additions and 22 deletions
+2 -2
View File
@@ -78,8 +78,8 @@ int neu_mqtt_client_set_connect_cb(neu_mqtt_client_t * client,
int neu_mqtt_client_set_disconnect_cb(neu_mqtt_client_t * client,
neu_mqtt_client_connection_cb_t cb,
void * data);
int neu_mqtt_client_set_tls(neu_mqtt_client_t *client, bool enabled,
const char *ca, const char *cert, const char *key,
int neu_mqtt_client_set_tls(neu_mqtt_client_t *client, const char *ca,
const char *cert, const char *key,
const char *keypass);
int neu_mqtt_client_set_cache_size(neu_mqtt_client_t *client,
size_t mem_size_bytes, size_t db_size_bytes);
+2 -2
View File
@@ -151,8 +151,8 @@ static int config_mqtt_client(neu_plugin_t *plugin, neu_mqtt_client_t *client,
}
// when config->ca is NULL tls will be disabled
rv = neu_mqtt_client_set_tls(client, true, config->ca, config->cert,
config->key, config->keypass);
rv = neu_mqtt_client_set_tls(client, config->ca, config->cert, config->key,
config->keypass);
if (0 != rv) {
plog_error(plugin, "neu_mqtt_client_set_tsl fail");
return -1;
+2 -2
View File
@@ -146,8 +146,8 @@ static int config_mqtt_client(neu_plugin_t *plugin, neu_mqtt_client_t *client,
}
// when config->ca is NULL tls will be disabled
rv = neu_mqtt_client_set_tls(client, true, config->ca, config->cert,
config->key, config->keypass);
rv = neu_mqtt_client_set_tls(client, config->ca, config->cert, config->key,
config->keypass);
if (0 != rv) {
plog_error(plugin, "neu_mqtt_client_set_tsl fail");
return -1;
+4 -16
View File
@@ -1005,8 +1005,8 @@ int neu_mqtt_client_set_disconnect_cb(neu_mqtt_client_t * client,
return 0;
}
int neu_mqtt_client_set_tls(neu_mqtt_client_t *client, bool enabled,
const char *ca, const char *cert, const char *key,
int neu_mqtt_client_set_tls(neu_mqtt_client_t *client, const char *ca,
const char *cert, const char *key,
const char *keypass)
{
int rv = 0;
@@ -1015,7 +1015,7 @@ int neu_mqtt_client_set_tls(neu_mqtt_client_t *client, bool enabled,
nng_mtx_lock(client->mtx);
return_failure_if_open();
if (!enabled) {
if (NULL == ca) {
// disable tls
log(debug, "tls disabled");
if (client->tls_cfg) {
@@ -1025,12 +1025,6 @@ int neu_mqtt_client_set_tls(neu_mqtt_client_t *client, bool enabled,
goto end;
}
if (NULL == client->host) {
log(error, "no client host");
rv = -1;
goto end;
}
if (client->tls_cfg) {
cfg = client->tls_cfg;
} else {
@@ -1043,12 +1037,6 @@ int neu_mqtt_client_set_tls(neu_mqtt_client_t *client, bool enabled,
client->tls_cfg = cfg;
}
if (0 != (rv = nng_tls_config_server_name(client->tls_cfg, client->host))) {
log(error, "nng_tls_config_server_name fail: %s", nng_strerror(rv));
rv = -1;
goto end;
}
if (cert != NULL && key != NULL) {
if ((rv = nng_tls_config_auth_mode(cfg, NNG_TLS_AUTH_MODE_REQUIRED)) !=
0) {
@@ -1069,7 +1057,7 @@ int neu_mqtt_client_set_tls(neu_mqtt_client_t *client, bool enabled,
}
}
if (ca && (rv = nng_tls_config_ca_chain(cfg, ca, NULL)) != 0) {
if ((rv = nng_tls_config_ca_chain(cfg, ca, NULL)) != 0) {
log(error, "nng_tls_config_ca_chain fail: %s", nng_strerror(rv));
rv = -1;
}