Skip to content

Commit 3621352

Browse files
committed
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>
1 parent d67d350 commit 3621352

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/nxt_controller.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,9 +1908,9 @@ nxt_controller_process_cert_save(nxt_task_t *task, nxt_port_recv_msg_t *msg,
19081908
static nxt_bool_t
19091909
nxt_controller_cert_in_use(nxt_str_t *name)
19101910
{
1911-
uint32_t next;
1911+
uint32_t i, n, next;
19121912
nxt_str_t str;
1913-
nxt_conf_value_t *listeners, *listener, *value;
1913+
nxt_conf_value_t *listeners, *listener, *value, *element;
19141914

19151915
static const nxt_str_t listeners_path = nxt_string("/listeners");
19161916
static const nxt_str_t certificate_path = nxt_string("/tls/certificate");
@@ -1931,10 +1931,27 @@ nxt_controller_cert_in_use(nxt_str_t *name)
19311931
continue;
19321932
}
19331933

1934-
nxt_conf_get_string(value, &str);
1934+
if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
1935+
n = nxt_conf_array_elements_count(value);
19351936

1936-
if (nxt_strstr_eq(&str, name)) {
1937-
return 1;
1937+
for (i = 0; i < n; i++) {
1938+
element = nxt_conf_get_array_element(value, i);
1939+
1940+
nxt_conf_get_string(element, &str);
1941+
1942+
if (nxt_strstr_eq(&str, name)) {
1943+
return 1;
1944+
}
1945+
}
1946+
1947+
} else {
1948+
/* NXT_CONF_STRING */
1949+
1950+
nxt_conf_get_string(value, &str);
1951+
1952+
if (nxt_strstr_eq(&str, name)) {
1953+
return 1;
1954+
}
19381955
}
19391956
}
19401957
}

0 commit comments

Comments
 (0)