security/acme-client: support uploading certificate to Vault, closes #2796

This commit is contained in:
Frank Wall
2022-07-27 16:51:27 +02:00
parent b773bfec87
commit f7a9483bc1
4 changed files with 93 additions and 3 deletions
+4 -3
View File
@@ -11,9 +11,10 @@ Plugin Changelog
3.12
Added:
* Add Simply.com DNS API (#2888)
* Add Active24 challenge type (#3049)
* Add support for Zone ID in Cloudflare challenge type (#2973)
* add Simply.com DNS API (#2888)
* add Active24 challenge type (#3049)
* add support for Zone ID in Cloudflare challenge type (#2973)
* new automation: upload certificate to Vault (#2796)
Fixed:
* Re-order function parameters due to PHP8 deprecation notice (#3043)
@@ -274,4 +274,27 @@
<type>text</type>
<help>Path to the Unifi keystore file in the local filesystem, i.e. /usr/local/share/java/unifi/data/keystore.</help>
</field>
<field>
<label>Required Parameters</label>
<type>header</type>
<style>method_table method_table_acme_vault</style>
</field>
<field>
<id>action.acme_vault_url</id>
<label>Vault URL</label>
<type>text</type>
<help>URL of the Vault, i.e. http://vault.example.com:8200.</help>
</field>
<field>
<id>action.acme_vault_prefix</id>
<label>Vault Prefix</label>
<type>text</type>
<help>This specifies the prefix path in Vault.</help>
</field>
<field>
<id>action.acme_vault_kvv2</id>
<label>Use KV v2</label>
<type>checkbox</type>
<help>If checked version 2 of the kv store will be used, otherwise version 1.</help>
</field>
</form>
@@ -0,0 +1,51 @@
<?php
/*
* Copyright (C) 2022 Frank Wall
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace OPNsense\AcmeClient\LeAutomation;
use OPNsense\AcmeClient\LeAutomationInterface;
/**
* Run acme.sh deploy hook vault
* @package OPNsense\AcmeClient
*/
class AcmeVault extends Base implements LeAutomationInterface
{
public function prepare()
{
$this->acme_env['VAULT_ADDR'] = (string)$this->config->acme_vault_url;
if (!empty((string)$this->config->acme_vault_prefix)) {
$this->acme_env['VAULT_PREFIX'] = (string)$this->config->acme_vault_prefix;
}
if ((string)$this->config->acme_vault_kvv2 == 1) {
$this->acme_env['VAULT_KV_V2'] = 1;
}
$this->acme_args[] = '--deploy-hook vault';
return true;
}
}
@@ -1129,6 +1129,7 @@
<configd_upload_sftp>Upload certificate via SFTP</configd_upload_sftp>
<configd_remote_ssh>Remote Command via SSH</configd_remote_ssh>
<acme_fritzbox>Upload certificate to FRITZ!Box router</acme_fritzbox>
<acme_vault>Upload certificate to HashiCorp Vault</acme_vault>
<acme_synology_dsm>Upload certificate to Synology DSM</acme_synology_dsm>
<acme_unifi>Update local Unifi keystore</acme_unifi>
<configd_generic>System or Plugin Command</configd_generic>
@@ -1325,6 +1326,20 @@
<default>/usr/local/share/java/unifi/data/keystore</default>
<Required>N</Required>
</acme_unifi_keystore>
<acme_vault_url type="TextField">
<Required>N</Required>
<mask>/^.{1,1024}$/u</mask>
<ValidationMessage>Should be a string between 1 and 1024 characters.</ValidationMessage>
</acme_vault_url>
<acme_vault_prefix type="TextField">
<default>acme</default>
<Required>N</Required>
<mask>/^.{1,1024}$/u</mask>
<ValidationMessage>Should be a string between 1 and 1024 characters.</ValidationMessage>
</acme_vault_prefix>
<acme_vault_kvv2 type="BooleanField">
<default>1</default>
</acme_vault_kvv2>
</action>
</actions>
</items>