mirror of
https://github.com/emqx/neuron.git
synced 2026-10-27 04:19:50 +08:00
Merge pull request #1463 from eeff/v2.5
Pick to v2.5 fix(mqtt): SSL check server name
This commit is contained in:
@@ -1025,6 +1025,12 @@ 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 {
|
||||
@@ -1037,6 +1043,12 @@ 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) {
|
||||
|
||||
Reference in New Issue
Block a user