From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 0EA071FF129 for ; Thu, 06 Aug 2026 15:53:18 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9F9F121524; Thu, 06 Aug 2026 15:53:18 +0200 (CEST) Date: Thu, 06 Aug 2026 15:53:11 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= Subject: applied: [PATCH datacenter-manager v3 13/16] cli: expose certificate management endpoints via the cli To: pbs-devel@lists.proxmox.com, Shannon Sterz References: <20260805155308.519896-2-s.sterz@proxmox.com> <20260805155308.519896-15-s.sterz@proxmox.com> In-Reply-To: <20260805155308.519896-15-s.sterz@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.17.0 (https://github.com/astroidmail/astroid) Message-Id: <1786024383.mlfu794p79.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1786024379482 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.102 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: VUJB6JDGI2FAV32Z3W53L5AVMEBWNRUT X-Message-ID-Hash: VUJB6JDGI2FAV32Z3W53L5AVMEBWNRUT X-MailFrom: f.gruenbichler@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On August 5, 2026 5:53 pm, Shannon Sterz wrote: > analogous to how this is handled in proxmox-backup-server. >=20 > Signed-off-by: Shannon Sterz > --- > cli/admin/Cargo.toml | 1 + > cli/admin/src/cert.rs | 86 +++++++++++++++++++++++++++++++++++++++++++ > cli/admin/src/main.rs | 2 + > 3 files changed, 89 insertions(+) > create mode 100644 cli/admin/src/cert.rs >=20 > diff --git a/cli/admin/Cargo.toml b/cli/admin/Cargo.toml > index 01afc88d..db522696 100644 > --- a/cli/admin/Cargo.toml > +++ b/cli/admin/Cargo.toml > @@ -29,3 +29,4 @@ pdm-api-types.workspace =3D true > pdm-config.workspace =3D true > pdm-buildcfg.workspace =3D true > server.workspace =3D true > +proxmox-time.workspace =3D true > diff --git a/cli/admin/src/cert.rs b/cli/admin/src/cert.rs > new file mode 100644 > index 00000000..6877c998 > --- /dev/null > +++ b/cli/admin/src/cert.rs > @@ -0,0 +1,86 @@ > +use anyhow::{Error, bail}; > + > +use proxmox_router::cli::*; > +use proxmox_schema::api; > +use server::api; > +use server::auth::certs::update_self_signed_cert; > +use server::auth::csrf::generate_csrf_key; > +use server::auth::key::generate_auth_key; > + > +#[api] > +/// Display node certificate information. > +fn cert_info() -> Result<(), Error> { > + let Some(cert) =3D api::nodes::certificates::get_info()?.pop() else = { > + return Ok(()); > + }; > + > + println!("Subject: {}", cert.subject); > + > + for name in cert.san { > + println!(" {name}"); > + } > + > + let not_before =3D cert > + .notbefore > + .and_then(|e| proxmox_time::strftime_utc("%b %e %T %Y %Z", e).ok= ()); > + > + let not_after =3D cert > + .notafter > + .and_then(|e| proxmox_time::strftime_utc("%b %e %T %Y %Z", e).ok= ()); > + > + println!("Issuer: {}", cert.issuer); > + println!("Validity:"); > + println!(" Not Before: {}", not_before.unwrap_or_default()); > + println!(" Not After : {}", not_after.unwrap_or_default()); > + > + println!( > + "Fingerprint (sha256): {}", > + cert.fingerprint.unwrap_or_default() > + ); > + > + println!("Public key type: {}", cert.public_key_type); > + println!( > + "Public key bits: {}", > + cert.public_key_bits.unwrap_or_default() > + ); > + > + Ok(()) > +} > + > +#[api( > + input: { > + properties: { > + force: { > + description: "Force generation of new SSL certificate.", > + type: Boolean, > + optional:true, > + }, > + } > + }, > +)] > +/// Update node certificates and generate all needed files/directories. = If no authentication key or > +/// CSRF secret key exists, this will also generate new ones. These two = keys will go into effect the > +/// next time the `proxmox-datacenter-api.service` is started. > +fn update_certs(force: Option) -> Result<(), Error> { > + pdm_config::setup::create_configdir()?; > + > + if let Err(err) =3D generate_auth_key() { > + bail!("unable to generate auth key - {err}"); > + } > + > + if let Err(err) =3D generate_csrf_key() { > + bail!("unable to generate csrf key - {err}"); > + } > + > + update_self_signed_cert(force.unwrap_or(false))?; > + > + Ok(()) > +} > + > +pub fn cert_mgmt_cli() -> CommandLineInterface { > + let cmd_def =3D CliCommandMap::new() > + .insert("info", CliCommand::new(&API_METHOD_CERT_INFO)) > + .insert("update", CliCommand::new(&API_METHOD_UPDATE_CERTS)); > + > + cmd_def.into() > +} > diff --git a/cli/admin/src/main.rs b/cli/admin/src/main.rs > index 3102694e..a2c5c623 100644 > --- a/cli/admin/src/main.rs > +++ b/cli/admin/src/main.rs > @@ -13,6 +13,7 @@ use proxmox_schema::api; > use proxmox_sys::fs::CreateOptions; > =20 > mod acme; > +mod cert; > mod remotes; > mod support_status; > =20 > @@ -39,6 +40,7 @@ async fn run() -> Result<(), Error> { > =20 > let cmd_def =3D CliCommandMap::new() > .insert("acme", acme::acme_mgmt_cli()) > + .insert("cert", cert::cert_mgmt_cli()) > .insert("remote", remotes::cli()) > .insert( > "report", > --=20 > 2.47.3 >=20 >=20 >=20 >=20 >=20 >=20