From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api] use fingerprint-sha256 option for fingerprints
Date: Wed, 22 Oct 2025 14:06:16 +0200 [thread overview]
Message-ID: <20251022120617.281408-1-m.sandoval@proxmox.com> (raw)
The previous parameter had a regex expression that allowed letters [A-Z]
instead of [A-F] and it was uppercase-only.
Tested via:
```
pmgcm join $HOST --fingerprint $FINGERPRINT
pmgcm status
```
Additionally it was tested that 'pmgcm status' worked after changing the
fingerprints at /etc/pmg/cluster.conf to lowercase.
Here $FINGERPRINT was modified so it contained both upper-and-lowercase
characters.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PMG/API2/Cluster.pm | 9 ++++-----
src/PMG/CLI/pmgcm.pm | 12 ++++++------
src/PMG/ClusterConfig.pm | 12 +++++++-----
3 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/PMG/API2/Cluster.pm b/src/PMG/API2/Cluster.pm
index fbfbcfc2..69096df6 100644
--- a/src/PMG/API2/Cluster.pm
+++ b/src/PMG/API2/Cluster.pm
@@ -421,11 +421,7 @@ __PACKAGE__->register_method({
type => 'string',
format => 'ip',
},
- fingerprint => {
- description => "SSL certificate fingerprint.",
- type => 'string',
- pattern => '^(:?[A-Z0-9][A-Z0-9]:){31}[A-Z0-9][A-Z0-9]$',
- },
+ fingerprint => get_standard_option('fingerprint-sha256'),
password => {
description => "Superuser password.",
type => 'string',
@@ -439,6 +435,9 @@ __PACKAGE__->register_method({
my $rpcenv = PMG::RESTEnvironment->get();
my $authuser = $rpcenv->get_user();
+ if (my $fp = $param->{fingerprint}) {
+ $param->{fingerprint} = uc($fp);
+ }
my $realcmd = sub {
my $cinfo = PMG::ClusterConfig->new();
diff --git a/src/PMG/CLI/pmgcm.pm b/src/PMG/CLI/pmgcm.pm
index 401f6801..07ea0741 100644
--- a/src/PMG/CLI/pmgcm.pm
+++ b/src/PMG/CLI/pmgcm.pm
@@ -6,6 +6,7 @@ use Data::Dumper;
use POSIX qw(strftime);
use JSON;
+use PVE::JSONSchema qw(get_standard_option);
use PVE::SafeSyslog;
use PVE::Tools qw(extract_param);
use PVE::INotify;
@@ -171,18 +172,17 @@ __PACKAGE__->register_method({
type => 'string',
format => 'ip',
},
- fingerprint => {
- description => "SSL certificate fingerprint.",
- type => 'string',
- pattern => '^(:?[A-Z0-9][A-Z0-9]:){31}[A-Z0-9][A-Z0-9]$',
- optional => 1,
- },
+ fingerprint => get_standard_option('fingerprint-sha256'),
},
},
returns => { type => 'null' },
code => sub {
my ($param) = @_;
+ if (my $fp = $param->{fingerprint}) {
+ $param->{fingerprint} = uc($fp);
+ }
+
my $code = sub {
my $cinfo = PMG::ClusterConfig->new();
diff --git a/src/PMG/ClusterConfig.pm b/src/PMG/ClusterConfig.pm
index bf8405c0..eeab326b 100644
--- a/src/PMG/ClusterConfig.pm
+++ b/src/PMG/ClusterConfig.pm
@@ -75,11 +75,7 @@ sub properties {
type => 'string',
pattern => valid_ssh_pubkey_regex(),
},
- fingerprint => {
- description => "SSL certificate fingerprint.",
- type => 'string',
- pattern => '^(:?[A-Z0-9][A-Z0-9]:){31}[A-Z0-9][A-Z0-9]$',
- },
+ fingerprint => PVE::JSONSchema::get_standard_option('fingerprint-sha256'),
};
}
@@ -203,6 +199,8 @@ sub read_cluster_conf {
$maxcid = $d->{maxcid} if defined($d->{maxcid}) && $d->{maxcid} > $maxcid;
$cinfo->{master} = $d if $d->{type} eq 'master';
$cinfo->{'local'} = $d if $d->{name} eq $localname;
+
+ $d->{fingerprint} = uc($d->{fingerprint});
}
if ($maxcid) {
@@ -224,6 +222,10 @@ sub read_cluster_conf {
sub write_cluster_conf {
my ($filename, $fh, $cfg) = @_;
+ foreach my $entry (values %{ $cfg->{ids} }) {
+ $entry->{fingerprint} = uc($entry->{fingerprint});
+ }
+
my $raw = PMG::ClusterConfig::Base->write_config($filename, $cfg);
PVE::Tools::safe_print($filename, $fh, $raw);
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
next reply other threads:[~2025-10-22 12:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 12:06 Maximiliano Sandoval [this message]
2025-10-23 8:33 ` Fabian Grünbichler
2025-10-23 8:51 ` Maximiliano Sandoval
2025-10-23 9:22 ` Fabian Grünbichler
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=20251022120617.281408-1-m.sandoval@proxmox.com \
--to=m.sandoval@proxmox.com \
--cc=pmg-devel@lists.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