From 32d4709f75767a823ce65539712296cc4e2713cf Mon Sep 17 00:00:00 2001 From: razzaguhl Date: Mon, 2 Dec 2024 17:22:29 +0100 Subject: [PATCH] script generate_certs: Multiple comma-separated refid values are possible. Use explode() and process them with a foreach loop --- .../scripts/Freeradius/generate_certs.php | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/net/freeradius/src/opnsense/scripts/Freeradius/generate_certs.php b/net/freeradius/src/opnsense/scripts/Freeradius/generate_certs.php index efb5eabd0f..a55e822d0d 100755 --- a/net/freeradius/src/opnsense/scripts/Freeradius/generate_certs.php +++ b/net/freeradius/src/opnsense/scripts/Freeradius/generate_certs.php @@ -80,17 +80,21 @@ $cert_refid = (string)$find_cert->ca; // if eap has a ca-certificate attached, search for its contents if ($cert_refid != "") { - foreach ($configObj->ca as $ca) { - if ($cert_refid == (string)$ca->refid) { - // generate cert pem file - $pem_content = trim(str_replace("\n\n", "\n", str_replace( - "\r", - "", - base64_decode((string)$ca->crt) - ))); - - $pem_content .= "\n"; - $ca_pem_content .= $pem_content; + // multiple comma-separated refid values are possible + $cert_refids = explode(',', $cert_refid); + foreach ($cert_refids as $current_refid) { + foreach ($configObj->ca as $ca) { + if ($current_refid == (string)$ca->refid) { + // generate cert pem file + $pem_content = trim(str_replace("\n\n", "\n", str_replace( + "\r", + "", + base64_decode((string)$ca->crt) + ))); + + $pem_content .= "\n"; + $ca_pem_content .= $pem_content; + } } } }