[pve-devel] [Patch V2 acme 10/12] Refactor extract_callenge for code reuse.
Wolfgang Link
w.link at proxmox.com
Tue Mar 31 12:08:49 CEST 2020
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
More information about the pve-devel
mailing list