public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>, Stefan Sterz <s.sterz@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup] fix #3867: server/api: send emails on certificate renewal failure
Date: Tue, 22 Mar 2022 15:37:39 +0100	[thread overview]
Message-ID: <3fe4c75f-038b-2115-db94-e57923c835ed@proxmox.com> (raw)
In-Reply-To: <20220308120214.1479855-1-s.sterz@proxmox.com>

On 08.03.22 13:02, Stefan Sterz wrote:
> the superuser's email will be used to notify them that certificate
> renewal has failed. also adds support for a notification setting to
> `node.cfg` and the api so that emails are sent either always, on
> error or never(similar to datastore notifications).
> 
> Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
> ---
> not sure if adding this setting to the gui is usefull and if so, where
> should we put it? if we put it next to the acme account setting, users
> might be confused as to which email will be used for notifications
> (acme vs. superuser's).

hmm, on a second thought I'd really prefer to start out as fixed, non-configurable,
on-error setting internally, we can always add the config option transparently later
on, if really requested.

To answer the original question: If we'd add it the gui entry would be useful, most
settings without gui are hidden for ~ over 90% of our users.

> @@ -536,11 +537,23 @@ fn spawn_certificate_worker(
>      let auth_id = rpcenv.get_auth_id().unwrap();
>  
>      WorkerTask::spawn(name, None, auth_id, true, move |worker| async move {
> -        if let Some(cert) = order_certificate(worker, &node_config).await? {
> -            crate::config::set_proxy_certificate(&cert.certificate, &cert.private_key_pem)?;
> -            crate::server::reload_proxy_certificate().await?;
> -        }
> -        Ok(())
> +        let work = || async {
> +            if let Some(cert) = order_certificate(worker, &node_config).await? {
> +                crate::config::set_proxy_certificate(&cert.certificate, &cert.private_key_pem)?;
> +                crate::server::reload_proxy_certificate().await?;
> +            }
> +
> +            Ok(())
> +        };
> +
> +        let res = work().await;
> +
> +        send_certificate_renewal_mail(
> +            node_config.renewal_notification.unwrap_or(Notify::Error),
> +            &res,
> +        )?;
> +
> +        res
>      })
>  }
>  

> diff --git a/src/config/node.rs b/src/config/node.rs
> index 0ba87450..87046ad4 100644
> --- a/src/config/node.rs
> +++ b/src/config/node.rs

> @@ -210,6 +216,10 @@ pub struct NodeConfig {
>      /// Default language used in the GUI
>      #[serde(skip_serializing_if = "Option::is_none")]
>      pub default_lang: Option<String>,
> +
> +    /// Whether to report certificate renewale on failure, always, never

typo: s/renewale/renewal/

> +    #[serde(skip_serializing_if = "Option::is_none")]
> +    pub renewal_notification: Option<Notify>,

IMO an ambiguous option name for the node.cfg, i.e., if I read this in the config 
I cannot know "what" gets renewed, so iff we'd have such a config it should probably
be named "acme_renewal_notify", but as written above, I'd avoid it for now and set
on-error

>  }
>  
>  impl NodeConfig {
> diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
> index 4d734368..347bc25d 100644
> --- a/src/server/email_notifications.rs
> +++ b/src/server/email_notifications.rs

> +
> +const ACME_CERTIFICATE_ERR_RENEWAL: &str = r###"
> +
> +Proxmox Backup Server was not able to renew a TLS certificate.

maybe: s/a/its/ 

> +
> +Encountered an error: {{error}}

Just "Error: {{error}}"

or

"... renew its TLS certificate:

{{error}}


Please..."

but not too hard feelings on that one.

> +
> +Please visit the web interface for further details:
> +
> +<https://{{fqdn}}:{{port}}/#pbsCertificateConfiguration>
> +
> +"###;
> +
>  lazy_static::lazy_static!{
>  
>      static ref HANDLEBARS: Handlebars<'static> = {






      reply	other threads:[~2022-03-22 14:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 12:02 Stefan Sterz
2022-03-22 14:37 ` Thomas Lamprecht [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3fe4c75f-038b-2115-db94-e57923c835ed@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=s.sterz@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal