Skip to content

Commit

Permalink
script generate_certs: Multiple comma-separated refid values are poss…
Browse files Browse the repository at this point in the history
…ible. Use explode() and process them with a foreach loop
  • Loading branch information
razza-guhl committed Dec 2, 2024
1 parent 455218a commit 32d4709
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions net/freeradius/src/opnsense/scripts/Freeradius/generate_certs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit 32d4709

Please sign in to comment.