]> git.proxmox.com Git - proxmox-acme.git/blobdiff - src/PVE/ACME/Challenge.pm
plugins: remove get_subplugins
[proxmox-acme.git] / src / PVE / ACME / Challenge.pm
index 0137cf22274fe85dc98b7a8592dbfbe8437a9e70..16d75ad7be41e99017db7832c14a8dffdb7ce380 100644 (file)
@@ -48,26 +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();
 
-    my $challenge = $tmp_challenges->[0];
+    # preference returned by plugin!
+    foreach my $supported_type (@$supported_types) {
+       foreach my $challenge (@$challenges) {
+           next if $challenge->{type} ne $supported_type;
 
-    return $challenge;
-}
+           return $challenge;
+       }
+    }
 
-sub get_subplugins {
-    return [];
+    die "plugin does not support any of the requested challenge types\n";
 }
 
 # acme => PVE::ACME instance