public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Stoiko Ivanov <s.ivanov@proxmox.com>
Subject: Re: [pve-devel] [PATCH manager 1/3] api: acme: set http_proxy if configured in datacenter.cfg
Date: Tue, 9 Nov 2021 18:08:49 +0100	[thread overview]
Message-ID: <e00df9f2-7ad4-fa39-bbd0-283dcadcbe86@proxmox.com> (raw)
In-Reply-To: <20211109163633.1721670-5-s.ivanov@proxmox.com>

On 09.11.21 17:36, Stoiko Ivanov wrote:
> partially fixes #3536
> 
> If a http_proxy is set in the datacenter config, use it for
> communicating with the (usually public) Acme provider.
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>  PVE/API2/ACME.pm        | 13 +++++++++++++
>  PVE/API2/ACMEAccount.pm | 17 +++++++++++++++++
>  2 files changed, 30 insertions(+)

for the record, needs versioned dependency bump on libproxmox-acme-perl >> 1.4.0 once
uploaded.

> diff --git a/PVE/API2/ACME.pm b/PVE/API2/ACME.pm
> index 393e6b01..6e6f44f6 100644
> --- a/PVE/API2/ACME.pm
> +++ b/PVE/API2/ACME.pm
> @@ -6,6 +6,7 @@ use warnings;
>  use PVE::ACME;
>  use PVE::CertHelpers;
>  use PVE::Certificate;
> +use PVE::Cluster;
>  use PVE::Exception qw(raise raise_param_exc);
>  use PVE::JSONSchema qw(get_standard_option);
>  use PVE::NodeConfig;
> @@ -207,6 +208,10 @@ __PACKAGE__->register_method ({
>  		if ! -e $account_file;
>  
>  	    my $acme = PVE::ACME->new($account_file);
> +	    my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
> +	    if (my $http_proxy = $dccfg->{http_proxy}) {
> +		$acme->set_proxy($http_proxy);
> +	    }
>  
>  	    print "Loading ACME account details\n";
>  	    $acme->load();
> @@ -284,6 +289,10 @@ __PACKAGE__->register_method ({
>  		if ! -e $account_file;
>  
>  	    my $acme = PVE::ACME->new($account_file);
> +	    my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
> +	    if (my $http_proxy = $dccfg->{http_proxy}) {
> +		$acme->set_proxy($http_proxy);
> +	    }
>  
>  	    print "Loading ACME account details\n";
>  	    $acme->load();
> @@ -352,6 +361,10 @@ __PACKAGE__->register_method ({
>  		if ! -e $account_file;
>  
>  	    my $acme = PVE::ACME->new($account_file);
> +	    my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
> +	    if (my $http_proxy = $dccfg->{http_proxy}) {
> +		$acme->set_proxy($http_proxy);
> +	    }
>  
>  	    print "Loading ACME account details\n";
>  	    $acme->load();
> diff --git a/PVE/API2/ACMEAccount.pm b/PVE/API2/ACMEAccount.pm
> index b790843a..218b84fe 100644
> --- a/PVE/API2/ACMEAccount.pm
> +++ b/PVE/API2/ACMEAccount.pm
> @@ -5,6 +5,7 @@ use warnings;
>  
>  use PVE::ACME;
>  use PVE::CertHelpers;
> +use PVE::Cluster;
>  use PVE::Exception qw(raise_param_exc);
>  use PVE::JSONSchema qw(get_standard_option);
>  use PVE::RPCEnvironment;
> @@ -142,6 +143,10 @@ __PACKAGE__->register_method ({
>  		    if -e $account_file;
>  
>  		my $acme = PVE::ACME->new($account_file, $directory);
> +		my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
> +		if (my $http_proxy = $dccfg->{http_proxy}) {
> +		    $acme->set_proxy($http_proxy);
> +		}
>  		print "Generating ACME account key..\n";
>  		$acme->init(4096);
>  		print "Registering ACME account..\n";
> @@ -177,6 +182,10 @@ my $update_account = sub {
>  		if ! -e $account_file;
>  
>  	    my $acme = PVE::ACME->new($account_file);
> +	    my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
> +	    if (my $http_proxy = $dccfg->{http_proxy}) {
> +		$acme->set_proxy($http_proxy);
> +	    }
>  	    $acme->load();
>  	    $acme->update_account(%info);
>  	    if ($info{status} && $info{status} eq 'deactivated') {
> @@ -276,6 +285,10 @@ __PACKAGE__->register_method ({
>  	    if ! -e $account_file;
>  
>  	my $acme = PVE::ACME->new($account_file);
> +	my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
> +	if (my $http_proxy = $dccfg->{http_proxy}) {
> +	    $acme->set_proxy($http_proxy);
> +	}
>  	$acme->load();
>  
>  	my $res = {};
> @@ -334,6 +347,10 @@ __PACKAGE__->register_method ({
>  	my $directory = extract_param($param, 'directory') // $acme_default_directory_url;
>  
>  	my $acme = PVE::ACME->new(undef, $directory);
> +	my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
> +	if (my $http_proxy = $dccfg->{http_proxy}) {
> +	    $acme->set_proxy($http_proxy);
> +	}
>  	my $meta = $acme->get_meta();
>  
>  	return $meta ? $meta->{termsOfService} : undef;
> 





  reply	other threads:[~2021-11-09 17:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 16:36 [pve-devel] [PATCH manager/proxmox-acme/pwt 0/3] fix #3536 add http proxy support for acme Stoiko Ivanov
2021-11-09 16:36 ` [pve-devel] [PATCH proxmox-acme 1/2] add support for proxies Stoiko Ivanov
2021-11-09 17:05   ` [pve-devel] applied: " Thomas Lamprecht
2021-11-09 16:36 ` [pve-devel] [PATCH proxmox-acme 2/2] dns-challenge: add 'use-proxy' property Stoiko Ivanov
2021-11-09 17:09   ` [pve-devel] applied: " Thomas Lamprecht
2021-11-09 16:36 ` [pve-devel] [PATCH widget-toolkit 1/1] acmeplugin: add use-proxy checkbox Stoiko Ivanov
2021-11-09 16:36 ` [pve-devel] [PATCH manager 1/3] api: acme: set http_proxy if configured in datacenter.cfg Stoiko Ivanov
2021-11-09 17:08   ` Thomas Lamprecht [this message]
2021-11-09 16:36 ` [pve-devel] [PATCH manager 2/3] api: acme: dns-plugin: conditionally pass proxy to acme.sh wrapper Stoiko Ivanov
2021-11-09 16:36 ` [pve-devel] [PATCH manager 3/3] gui: use acme plugin editor from proxmox-widget-toolkit Stoiko Ivanov

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=e00df9f2-7ad4-fa39-bbd0-283dcadcbe86@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=s.ivanov@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