mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user