mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
security/acme-client: remove saved deploy hook from acme.sh config files, fixes #3120
This commit is contained in:
@@ -18,9 +18,11 @@ Added:
|
||||
|
||||
Fixed:
|
||||
* fix Selfhost DNS API (#3122)
|
||||
* fix invalid cert state due to deploy error (#3120)
|
||||
|
||||
Changed:
|
||||
* change default DNS sleep time to 0 (3079)
|
||||
* change default DNS sleep time to 0 (#3079)
|
||||
* remove saved deploy hook from acme.sh config files (#3120)
|
||||
|
||||
3.13
|
||||
|
||||
|
||||
+27
@@ -150,6 +150,33 @@ abstract class Base extends \OPNsense\AcmeClient\LeCommon
|
||||
return false;
|
||||
}
|
||||
|
||||
// acme.sh records the last used deploy hook and would automatically
|
||||
// use it on the next run. This information must be removed from the
|
||||
// configuration file. Otherwise it would be impossible to disable
|
||||
// or remove a deploy hook from the GUI.
|
||||
foreach (glob(self::ACME_HOME_DIR . '/*/*.conf') as $filename) {
|
||||
// Skip openssl config files.
|
||||
if (preg_match('/.*.csr.conf/i', $filename)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Read contents from file.
|
||||
$contents = file_get_contents($filename);
|
||||
|
||||
// Check if deploy hook string can be found.
|
||||
if (strpos($contents, self::ACME_DEPLOY_HOOK_STRING) !== false) {
|
||||
// Replace the whole line with an empty string.
|
||||
$contents = preg_replace('(' . self::ACME_DEPLOY_HOOK_STRING . '.*)', '', $contents);
|
||||
|
||||
// Write changes to the file.
|
||||
if (!file_put_contents($filename, $contents)) {
|
||||
LeUtils::log_error('clearing recorded deploy hook from acme.sh failed (' . $filename . ')');
|
||||
} else {
|
||||
LeUtils::log_debug('cleared recorded deploy deploy hook from acme.sh (' . $filename . ')', $this->debug);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check result
|
||||
if ($result) {
|
||||
LeUtils::log_error('running acme.sh deploy hook failed (' . $this->getType() . ')');
|
||||
|
||||
@@ -59,6 +59,9 @@ abstract class LeCommon
|
||||
public const ACME_KEY_DIR = '/var/etc/acme-client/keys/%s/';
|
||||
public const ACME_KEY_FILE = '/var/etc/acme-client/keys/%s/private.key';
|
||||
|
||||
// acme.sh internals
|
||||
public const ACME_DEPLOY_HOOK_STRING = 'Le_DeployHook=';
|
||||
|
||||
// Runtime parameters for acme.sh
|
||||
protected $acme_args = array(); # command line arguments to be passed to acme.sh
|
||||
protected $acme_env = array(); # environment variables to be used when running acme.sh
|
||||
|
||||
Reference in New Issue
Block a user