[pve-devel] [Patch V2 acme 10/12] Refactor extract_callenge for code reuse.

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Apr 1 15:28:36 CEST 2020


order between this and 9 is wrong, and this introduces a circular 
dependency. extract_challenge would probably need to go into 
Challenge.pm? that way, new challenge types that don't need this/do it 
differently can override it as well..

On March 31, 2020 12:08 pm, Wolfgang Link wrote:
> Signed-off-by: Wolfgang Link <w.link at proxmox.com>
> ---
>  src/PVE/ACME.pm            | 15 +++++++++++++++
>  src/PVE/ACME/StandAlone.pm |  2 ++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/src/PVE/ACME.pm b/src/PVE/ACME.pm
> index c10dca2..7c0794a 100644
> --- a/src/PVE/ACME.pm
> +++ b/src/PVE/ACME.pm
> @@ -573,4 +573,19 @@ sub do {
>      return $res;
>  }
>  
> +sub extract_challenge ($$) {
> +    my ($challenges, $c_type) = @_;
> +
> +    die "no challenges defined\n" if !$challenges;
> +    die "no challenge type is defined \n" if !$c_type;
> +
> +    my $tmp_challenges = [ grep {$_->{type} eq $c_type} @$challenges ];
> +    die "no $c_type challenge defined in authorization\n"
> +	if ! scalar $tmp_challenges;
> +
> +    my $challenge = $tmp_challenges->[0];
> +
> +    return $challenge;
> +}
> +
>  1;
> diff --git a/src/PVE/ACME/StandAlone.pm b/src/PVE/ACME/StandAlone.pm
> index 8fc8dc9..38db3f8 100644
> --- a/src/PVE/ACME/StandAlone.pm
> +++ b/src/PVE/ACME/StandAlone.pm
> @@ -6,6 +6,8 @@ use warnings;
>  use HTTP::Daemon;
>  use HTTP::Response;
>  
> +use PVE::ACME;
> +
>  use base qw(PVE::ACME::Challenge);
>  
>  sub supported_challenge_types {
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 




More information about the pve-devel mailing list