public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Elias Huhsovitz" <e.huhsovitz@proxmox.com>
To: "Thomas Ellmenreich" <t.ellmenreich@proxmox.com>,
	<pve-devel@lists.proxmox.com>
Subject: Re: [PATCH proxmox-acme 1/1] fix #7749: always serialize in same order
Date: Wed, 22 Jul 2026 17:39:45 +0200	[thread overview]
Message-ID: <DK57OHJS55WH.FKHGDE7ATQ3U@proxmox.com> (raw)
In-Reply-To: <20260714090458.87511-2-t.ellmenreich@proxmox.com>

Small nit below, otherwise

Reviewed-by: Elias Huhsovitz <e.huhsovitz@proxmox.com>

On Tue Jul 14, 2026 at 11:04 AM CEST, Thomas Ellmenreich wrote:
> All objects are now serialized with "canonical => 1" so that the
> resulting bytes are directly comparable. Perls randomized hash key
> orders lead to different serialization outputs even with the same input.
>
> Signed-off-by: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
> ---
>  src/PVE/ACME.pm | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/PVE/ACME.pm b/src/PVE/ACME.pm
> index e6fb9c2..a5287ac 100644
> --- a/src/PVE/ACME.pm
> +++ b/src/PVE/ACME.pm
> @@ -64,9 +64,9 @@ sub encode($) { # acme requires 'base64url' encoding
>      return encode_base64url($_[0]);
>  }
>  
> -sub tojs($;%) { # shortcut for to_json with utf8=>1
> +sub tojs($;%) { # shortcut for to_json with utf8=>1 and canonical=>1
>      my ($data, %data) = @_;
> -    return to_json($data, { utf8 => 1, %data });
> +    return to_json($data, { utf8 => 1, canonical => 1, %data });
>  }

nit: change the ordering to:

return to_json($data, { %data, utf8 => 1, canonical => 1 });

To guarantee utf8=1, canonical=1. Theoretically %data could contain the
keys (utf8=0, canonical=0) overriding your manually set values, due to
perls hash expansion. Re-ordering should guarantee consistency.

>  
>  sub fromjs($) {
> @@ -155,7 +155,7 @@ sub save {
>      }
>      # pretty => 1 for readability
>      # canonical => 1 to reduce churn
> -    file_set_contents($self->{path}, tojs($o, pretty => 1, canonical => 1));
> +    file_set_contents($self->{path}, tojs($o, pretty => 1));
>  }
>  
>  # Load serialized account JSON file into $self
> @@ -196,7 +196,7 @@ sub jwk {
>  sub jwk_thumbprint {
>      my ($self) = @_;
>      my $jwk = $self->jwk(1); # $pure = 1
> -    return encode(sha256(tojs($jwk, canonical => 1))); # canonical sorts
> +    return encode(sha256(tojs($jwk)));
>  }
>  
>  # A key authorization string in acme is a challenge token dot-connected with





      reply	other threads:[~2026-07-22 15:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14  9:04 [PATCH proxmox-acme 0/1] fix #7749: always serialize in same order Thomas Ellmenreich
2026-07-14  9:04 ` [PATCH proxmox-acme 1/1] " Thomas Ellmenreich
2026-07-22 15:39   ` Elias Huhsovitz [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=DK57OHJS55WH.FKHGDE7ATQ3U@proxmox.com \
    --to=e.huhsovitz@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.ellmenreich@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