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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8BF9369EE0 for ; Fri, 12 Mar 2021 15:51:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 744EB342B8 for ; Fri, 12 Mar 2021 15:51:19 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6A4B4342AC for ; Fri, 12 Mar 2021 15:51:17 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 368FF463E1 for ; Fri, 12 Mar 2021 15:51:17 +0100 (CET) Date: Fri, 12 Mar 2021 15:51:14 +0100 From: Wolfgang Bumiller To: Dominik Csapak Cc: pmg-devel@lists.proxmox.com Message-ID: <20210312145114.h5s65pewiwmsajfl@wobu-vie.proxmox.com> References: <20210309141401.19237-1-w.bumiller@proxmox.com> <20210309141401.19237-7-w.bumiller@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.038 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [when.pm, action.pm, nodes.pm, certificates.pm, acmeplugin.pm, api2.pm, acme.pm, what.pm] Subject: Re: [pmg-devel] [PATCH api 6/8] add certificates api endpoint X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2021 14:51:49 -0000 On Thu, Mar 11, 2021 at 12:06:23PM +0100, Dominik Csapak wrote: > > > On 3/9/21 3:13 PM, Wolfgang Bumiller wrote: > > This adds /nodes/{nodename}/certificates endpoint > > containing: > > > > /custom/{type} - update smtp or api certificates manually > > /acme/{type} - update via acme > > > > Signed-off-by: Wolfgang Bumiller > > --- > > src/Makefile | 1 + > > src/PMG/API2/Certificates.pm | 690 +++++++++++++++++++++++++++++++++++ > > src/PMG/API2/Nodes.pm | 7 + > > 3 files changed, 698 insertions(+) > > create mode 100644 src/PMG/API2/Certificates.pm > > > > diff --git a/src/Makefile b/src/Makefile > > index ebc6bd8..e0629b2 100644 > > --- a/src/Makefile > > +++ b/src/Makefile > > @@ -155,6 +155,7 @@ LIBSOURCES = \ > > PMG/API2/When.pm \ > > PMG/API2/What.pm \ > > PMG/API2/Action.pm \ > > + PMG/API2/Certificates.pm \ > > PMG/API2/ACME.pm \ > > PMG/API2/ACMEPlugin.pm \ > > PMG/API2.pm \ > > diff --git a/src/PMG/API2/Certificates.pm b/src/PMG/API2/Certificates.pm > > new file mode 100644 > > index 0000000..d196af6 > > --- /dev/null > > +++ b/src/PMG/API2/Certificates.pm > > @@ -0,0 +1,690 @@ > > +package PMG::API2::Certificates; > > + > > +use strict; > > +use warnings; > > + > > +use PVE::Certificate; > > +use PVE::Exception qw(raise raise_param_exc); > > +use PVE::JSONSchema qw(get_standard_option); > > +use PVE::Tools qw(extract_param file_get_contents file_set_contents); > > + > > +use PMG::CertHelpers; > > +use PMG::NodeConfig; > > +use PMG::RS::CSR; > > + > > +use PMG::API2::ACMEPlugin; > > + > > +use base qw(PVE::RESTHandler); > > + > > +my $acme_account_dir = PMG::CertHelpers::acme_account_dir(); > > + > > +sub first_typed_pem_entry : prototype($$) { > > + my ($label, $data) = @_; > > + > > + if ($data =~ /^(-----BEGIN (?