config: acme: fall-back to the "default" account

syncs behavior with both, the displayed state in the PBS
web-interface, and the behavior of PVE/PMG.

Without this a standard setup would result in a Error like:
> TASK ERROR: no acme client configured

which was pretty confusing, as the actual error was something else
(no account configured), and the web-interface showed "default" as
selected account, so a user had no idea what actually was wrong and
how to fix it.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-05-11 17:33:06 +02:00
parent fca1cef29f
commit 38b4f9b534

View File

@ -2,7 +2,7 @@ use std::collections::HashSet;
use std::fs::File;
use std::time::Duration;
use anyhow::{bail, format_err, Error};
use anyhow::{bail, Error};
use nix::sys::stat::Mode;
use serde::{Deserialize, Serialize};
@ -138,13 +138,12 @@ impl NodeConfig {
}
pub async fn acme_client(&self) -> Result<AcmeClient, Error> {
AcmeClient::load(
&self
.acme_config()
.ok_or_else(|| format_err!("no acme client configured"))??
.account,
)
.await
let account = if let Some(cfg) = self.acme_config().transpose()? {
cfg.account
} else {
AcmeAccountName::from_string("default".to_string())? // should really not happen
};
AcmeClient::load(&account).await
}
pub fn acme_domains(&self) -> AcmeDomainIter {