Merge pull request #1463 from eeff/v2.5

Pick to v2.5 fix(mqtt): SSL check server name
This commit is contained in:
fengzeroz
2023-08-22 10:12:05 +08:00
committed by GitHub
+12
View File
@@ -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) {