net/freeradius: EAP-TLS with multiple CAs (#4381)

* controller eap: changed from dropdown to select_multiple

* model eap: add mulitple option to CertificateField type ca

* script generate_certs: Multiple comma-separated refid values are possible. Use explode() and process them with a foreach loop
This commit is contained in:
RasAlGhul
2025-01-14 10:51:41 +01:00
committed by GitHub
parent 1e4674a853
commit 2f4e63b03b
3 changed files with 17 additions and 12 deletions
@@ -20,7 +20,7 @@
<field>
<id>eap.ca</id>
<label>Root Certificate</label>
<type>dropdown</type>
<type>select_multiple</type>
<help>Choose the Root CA. This CA will be trusted to issue client certificates for authentication.</help>
</field>
<field>
@@ -31,6 +31,7 @@
<ca type="CertificateField">
<Type>ca</Type>
<Required>N</Required>
<multiple>Y</multiple>
</ca>
<certificate type="CertificateField">
<Type>cert</Type>
@@ -80,17 +80,21 @@ if (isset($configObj->OPNsense->freeradius)) {
$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;
}
}
}
}