mirror of
https://github.com/opnsense/plugins.git
synced 2026-06-04 22:33:07 -04:00
net/haproxy: fix certificate export
This commit is contained in:
parent
dec85ab09a
commit
f997189a77
1 changed files with 3 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue