summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_controller.c
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2024-07-01 12:36:39 +0800
committerZhidao HONG <z.hong@f5.com>2024-07-03 17:56:20 +0800
commit3621352278aa6a3ef760c2fdfbbec0c1310ec1e6 (patch)
treedf5690416565753e0df6e4e77fc39660e315f88c /src/nxt_controller.c
parentd67d350142d4ef9a9cdbfc2bb4a6b2d8f261deb1 (diff)
downloadunit-3621352278aa6a3ef760c2fdfbbec0c1310ec1e6.tar.gz
unit-3621352278aa6a3ef760c2fdfbbec0c1310ec1e6.tar.bz2
Fix certificate deletion for array type certificates
Previously, the certificate deletion only handled string type certificates, causing issues when certificates were specified as an array in the configuration. Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to '')
-rw-r--r--src/nxt_controller.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/nxt_controller.c b/src/nxt_controller.c
index b4ae8d09..1ffcf815 100644
--- a/src/nxt_controller.c
+++ b/src/nxt_controller.c
@@ -1908,9 +1908,9 @@ nxt_controller_process_cert_save(nxt_task_t *task, nxt_port_recv_msg_t *msg,
static nxt_bool_t
nxt_controller_cert_in_use(nxt_str_t *name)
{
- uint32_t next;
+ uint32_t i, n, next;
nxt_str_t str;
- nxt_conf_value_t *listeners, *listener, *value;
+ nxt_conf_value_t *listeners, *listener, *value, *element;
static const nxt_str_t listeners_path = nxt_string("/listeners");
static const nxt_str_t certificate_path = nxt_string("/tls/certificate");
@@ -1931,10 +1931,27 @@ nxt_controller_cert_in_use(nxt_str_t *name)
continue;
}
- nxt_conf_get_string(value, &str);
+ if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
+ n = nxt_conf_array_elements_count(value);
- if (nxt_strstr_eq(&str, name)) {
- return 1;
+ for (i = 0; i < n; i++) {
+ element = nxt_conf_get_array_element(value, i);
+
+ nxt_conf_get_string(element, &str);
+
+ if (nxt_strstr_eq(&str, name)) {
+ return 1;
+ }
+ }
+
+ } else {
+ /* NXT_CONF_STRING */
+
+ nxt_conf_get_string(value, &str);
+
+ if (nxt_strstr_eq(&str, name)) {
+ return 1;
+ }
}
}
}