global-functions: $CertificateNameByCN: fail on matching serveral certs

This commit is contained in:
Christian Hesse 2026-08-07 14:20:33 +02:00
parent 731ff26110
commit 4cac06774c

View file

@ -240,11 +240,17 @@
:return true;
}
:set Cert ([ /certificate/find where (common-name=$Match or fingerprint=$Match or name=$Match) ]->0);
:set Cert [ /certificate/find where common-name=$Match or fingerprint=$Match or name=$Match ];
:if ([ :len $Cert ] > 1) do={
$LogPrint warning $0 ("Too many matching certificates found.");
:return false;
}
:if ([ :len $Cert ] = 0) do={
$LogPrint warning $0 ("No matching certificate found.");
:return false;
}
:local CommonName [ /certificate/get $Cert common-name ];
/certificate/set $Cert name=[ $CleanName $CommonName ];
:return true;