X-Git-Url: https://git.proxmox.com/?p=proxmox-acme.git;a=blobdiff_plain;f=src%2FPVE%2FACME%2FChallenge.pm;h=5fb9cbe4adc66f8c135e5a866ad05af5b4036767;hp=0137cf22274fe85dc98b7a8592dbfbe8437a9e70;hb=122626b3d578721ffdbfbbbf47da4b09942f7635;hpb=f00829fd606b2d3f15828125527a7b6bfda6ba7f diff --git a/src/PVE/ACME/Challenge.pm b/src/PVE/ACME/Challenge.pm index 0137cf2..5fb9cbe 100644 --- a/src/PVE/ACME/Challenge.pm +++ b/src/PVE/ACME/Challenge.pm @@ -48,22 +48,26 @@ sub parse_config { } sub supported_challenge_types { - return {}; + return []; } sub extract_challenge { - my ($self, $challenges, $c_type) = @_; + my ($self, $challenges) = @_; 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 $supported_types = $self->supported_challenge_types(); + + # preference returned by plugin! + foreach my $supported_type (@$supported_types) { + foreach my $challenge (@$challenges) { + next if $challenge->{type} ne $supported_type; - my $challenge = $tmp_challenges->[0]; + return $challenge; + } + } - return $challenge; + die "plugin does not support any of the requested challenge types\n"; } sub get_subplugins {