From 4cac06774cf551b9b72f0814708d3fa0f6318348 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 7 Aug 2026 14:20:33 +0200 Subject: [PATCH] global-functions: $CertificateNameByCN: fail on matching serveral certs --- global-functions.rsc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/global-functions.rsc b/global-functions.rsc index 12a16b4e..e9e0a491 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -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;