From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 2FF8A9C454 for ; Tue, 24 Oct 2023 10:32:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 192211CF43 for ; Tue, 24 Oct 2023 10:32:50 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 24 Oct 2023 10:32:49 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3AB6144B01 for ; Tue, 24 Oct 2023 10:32:49 +0200 (CEST) Date: Tue, 24 Oct 2023 10:32:42 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20231023131808.172494-1-f.gleumes@proxmox.com> <20231023131808.172494-3-f.gleumes@proxmox.com> In-Reply-To: <20231023131808.172494-3-f.gleumes@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1698134500.8d6ows44rm.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.062 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH manager 2/5] fix #4497: acme: add support for external account bindings X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2023 08:32:50 -0000 On October 23, 2023 3:18 pm, Folke Gleumes wrote: > Signed-off-by: Folke Gleumes > --- > PVE/API2/ACMEAccount.pm | 27 ++++++++++++++++++++++++++- > 1 file changed, 26 insertions(+), 1 deletion(-) >=20 > diff --git a/PVE/API2/ACMEAccount.pm b/PVE/API2/ACMEAccount.pm > index b790843a..daae18d8 100644 > --- a/PVE/API2/ACMEAccount.pm > +++ b/PVE/API2/ACMEAccount.pm > @@ -115,6 +115,16 @@ __PACKAGE__->register_method ({ > default =3D> $acme_default_directory_url, > optional =3D> 1, > }), > + eab_kid =3D> { > + type =3D> 'string', > + description =3D> 'Key Identifier for External Account Binding.', > + optional =3D> 1, > + }, > + eab_hmac_key =3D> { > + type =3D> 'string', > + description =3D> 'HMAC key for External Account Binding.', > + optional =3D> 1, > + }, Nit: s/_/-/ for new parameters :) > }, > }, > returns =3D> { > @@ -130,8 +140,15 @@ __PACKAGE__->register_method ({ > my $account_file =3D "${acme_account_dir}/${account_name}"; > mkdir $acme_account_dir if ! -e $acme_account_dir; > =20 > + my $eab_kid =3D extract_param($param, 'eab_kid'); > + my $eab_hmac_key =3D extract_param($param, 'eab_hmac_key'); > + > raise_param_exc({'name' =3D> "ACME account config file '${account_name}= ' already exists."}) > if -e $account_file; > + raise_param_exc({'eab_kid' =3D> "'eab_hmac_key' must be defined if 'eab= _kid' is set."}) > + if defined($eab_kid) and not defined($eab_hmac_key); > + raise_param_exc({'eab_hmac_key' =3D> "'eab_kid' must be defined if 'eab= _hmac_key' is set."}) > + if defined($eab_hmac_key) and not defined($eab_kid); these two checks can be encoded directly in the schema by adding requires =3D> "name-of-require-parameter" to both definitions, pointing at the other one. if a caller only provides either of them and not both (or none), the schema check will error: eab_hmac_key: missing property - 'eab_kid' requires this property without needing any manual handling in the API endpoint handler sub. > =20 > my $directory =3D extract_param($param, 'directory') // $acme_default_d= irectory_url; > my $contact =3D $account_contact_from_param->($param); > @@ -145,7 +162,15 @@ __PACKAGE__->register_method ({ > print "Generating ACME account key..\n"; > $acme->init(4096); > print "Registering ACME account..\n"; > - eval { $acme->new_account($param->{tos_url}, contact =3D> $contact); }= ; > + my $info =3D {contact =3D> $contact}; > + if (defined($eab_kid) and defined($eab_hmac_key)) { > + $info->{eab} =3D { > + kid =3D> $eab_kid, > + hmac_key =3D> $eab_hmac_key > + }; > + } > + > + eval { $acme->new_account($param->{tos_url}, $info); }; if you switch this line to %$info or $info->%*, the new_account sub can still take the hash directly instead of a reference, but see comments on the proxmox-acme patch for possibly nicer signatures. > if (my $err =3D $@) { > unlink $account_file; > die "Registration failed: $err\n"; > --=20 > 2.39.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20