From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 9A97B1FF0ED for ; Fri, 14 Aug 2026 12:11:12 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 18A8C22306; Fri, 14 Aug 2026 12:11:12 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 14 Aug 2026 12:11:06 +0200 Message-Id: From: "Elias Huhsovitz" To: "Thomas Ellmenreich" , Subject: Re: [PATCH proxmox-acme v3 1/1] fix #7749: always serialize in same order X-Mailer: aerc 0.20.0 References: <20260812115128.135004-1-t.ellmenreich@proxmox.com> In-Reply-To: <20260812115128.135004-1-t.ellmenreich@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1786702248118 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.005 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) NUMERIC_HTTP_ADDR 0.001 Uses a numeric IP address in URL POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record WEIRD_PORT 0.001 Uses non-standard port number for HTTP Message-ID-Hash: JOP65NJ3NPNZBWIXFKIKRYOCRTT3HPYK X-Message-ID-Hash: JOP65NJ3NPNZBWIXFKIKRYOCRTT3HPYK X-MailFrom: e.huhsovitz@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 VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: I tested the changes in 2 ways: Test Process =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Calling tojs ------------ I directly called the updated tojs subroutine with different data (hash references) and optional paramters. The serialization order remained constant. pebble (letsencrypt) -------------------- I installed pebble from [1]. Ran=20 `PEBBLE_VA_ALWAYS_VALID=3D1 PEBBLE_WFE_NONCEREJECT=3D0 pebble -config ./tes= t/config/pebble-config.json` initialized a new ACME client againt pebble using=20 `my $acme =3D PVE::ACME->new('/tmp/pebble_test_account.json', "https://192.= 168.16.88:14000/dir")` then called `acme->new_account` and `$acme->new_order()` Pebble output seems fine: Pebble 2026/08/14 12:08:26 GET /dir -> calling handler() Pebble 2026/08/14 12:08:26 GET /nonce-plz -> calling handler() Pebble 2026/08/14 12:08:26 POST /sign-me-up -> calling handler() Pebble 2026/08/14 12:08:26 There are now 1 accounts in memory Pebble 2026/08/14 12:08:26 POST /order-plz -> calling handler() Pebble 2026/08/14 12:08:26 There are now 1 authorizations in the db Pebble 2026/08/14 12:08:26 Added order "d9M7evJN3JqyVwvKZxCBCrun1l9gKV7cegZ= DTYRKIRY" to the db Pebble 2026/08/14 12:08:26 There are now 1 orders in the db [1] https://github.com/letsencrypt/pebble Therefore consider this patch. Reviewed-by: Elias Huhsovitz Tested-by: Elias Huhsovitz On Wed Aug 12, 2026 at 1:51 PM CEST, Thomas Ellmenreich wrote: > All objects are now serialized with "canonical =3D> 1" so that the > resulting bytes are directly comparable. Perls randomized hash key > orders lead to different serialization outputs even with the same input. > > The 'tojs' function also now explicitly overrides the utf8 and canonical > options to make sure that they are always set. > > Signed-off-by: Thomas Ellmenreich > --- > Serializing acme responses to json, because of perls randomized hash key = order, > would lead to unequal serialized responses if they were compared as bytes= . By > setting "canonical =3D> 1" the serializations now always have the same or= der and > can thus be compared bytewise. > > I have tested the patch against a local instance of HashiCorp Vault PKI a= nd the > EAB registration works. > > It seems that "canonical" can have performance implications when serialis= ing > larger objects, but since the objects produced in our acme client are > relatively small, I consider this acceptable. > > Changes since v2 (thanks @Elias) > -------------------------------- > > - The options were beeing passed to the 'to_json' function as a hash > instead of a hash reference. This is now fixed. > > > src/PVE/ACME.pm | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/src/PVE/ACME.pm b/src/PVE/ACME.pm > index e6fb9c2..3756ac0 100644 > --- a/src/PVE/ACME.pm > +++ b/src/PVE/ACME.pm > @@ -64,9 +64,13 @@ sub encode($) { # acme requires 'base64url' encoding > return encode_base64url($_[0]); > } > =20 > -sub tojs($;%) { # shortcut for to_json with utf8=3D>1 > - my ($data, %data) =3D @_; > - return to_json($data, { utf8 =3D> 1, %data }); > +sub tojs($;%) { # shortcut for to_json with utf8=3D>1 and canonical=3D>1 > + my ($data, %opts) =3D @_; > + > + $opts{utf8} =3D 1; > + $opts{canonical} =3D 1; > + > + return to_json($data, \%opts); > } > =20 > sub fromjs($) { > @@ -155,7 +159,7 @@ sub save { > } > # pretty =3D> 1 for readability > # canonical =3D> 1 to reduce churn > - file_set_contents($self->{path}, tojs($o, pretty =3D> 1, canonical = =3D> 1)); > + file_set_contents($self->{path}, tojs($o, pretty =3D> 1)); > } > =20 > # Load serialized account JSON file into $self > @@ -196,7 +200,7 @@ sub jwk { > sub jwk_thumbprint { > my ($self) =3D @_; > my $jwk =3D $self->jwk(1); # $pure =3D 1 > - return encode(sha256(tojs($jwk, canonical =3D> 1))); # canonical sor= ts > + return encode(sha256(tojs($jwk))); > } > =20 > # A key authorization string in acme is a challenge token dot-connected = with