mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
net/haproxy: fix certificate export
This commit is contained in:
@@ -41,11 +41,11 @@ global $config;
|
||||
$configObj = Config::getInstance()->object();
|
||||
if (isset($configObj->OPNsense->HAProxy->frontends)) {
|
||||
foreach ($configObj->OPNsense->HAProxy->frontends->children() as $frontend) {
|
||||
if (!isset($frontend->ssl)) {
|
||||
if (!isset($frontend->ssl_enabled)) {
|
||||
continue;
|
||||
}
|
||||
// multiple comma-separated values are possible
|
||||
$certs = explode(',', $frontend->ssl->certificates);
|
||||
$certs = explode(',', $frontend->ssl_certificates);
|
||||
foreach ($certs as $cert_refid) {
|
||||
// if the frontend has a cert attached, search for its contents
|
||||
if ($cert_refid != "") {
|
||||
@@ -53,7 +53,7 @@ if (isset($configObj->OPNsense->HAProxy->frontends)) {
|
||||
if ($cert_refid == (string)$cert->refid) {
|
||||
// generate cert pem file
|
||||
$pem_content = str_replace("\n\n", "\n", str_replace("\r", "", base64_decode((string)$cert->crt)));
|
||||
$pem_content .= str_replace("\n\n", "\n", str_replace("\r", "", base64_decode((string)$cert->prv)));
|
||||
$pem_content .= "\n" . str_replace("\n\n", "\n", str_replace("\r", "", base64_decode((string)$cert->prv)));
|
||||
$output_pem_filename = "/var/etc/haproxy/ssl/" . $cert_refid . ".pem" ;
|
||||
file_put_contents($output_pem_filename, $pem_content);
|
||||
chmod($output_pem_filename, 0600);
|
||||
|
||||
Reference in New Issue
Block a user