[pve-devel] [common 7/9] implement the setup function for DNS challenge
Wolfgang Link
w.link at proxmox.com
Mon Oct 14 13:08:26 CEST 2019
---
src/PVE/ACME/ACME_sh.pm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/PVE/ACME/ACME_sh.pm b/src/PVE/ACME/ACME_sh.pm
index 40be772..e60fd93 100644
--- a/src/PVE/ACME/ACME_sh.pm
+++ b/src/PVE/ACME/ACME_sh.pm
@@ -5,6 +5,9 @@ use warnings;
use HTTP::Daemon;
use HTTP::Response;
+use Digest::SHA qw(sha256);
+
+use PVE::ACME;
use base qw(PVE::ACME::Challenge);
@@ -59,4 +62,24 @@ sub validating_url {
}
+my $outfunc = sub {
+ my $line = shift;
+ print "$line\n";
+};
+
+sub setup {
+ my ($class, $auth, $acme, $alias) = @_;
+
+ my $dns_challenge = PVE::ACME::extract_challenge($auth->{'challenges'}, "dns-01");
+ my $url = $dns_challenge->{'url'};
+ my $domain = $auth->{'identifier'}->{'value'};
+ my $key_auth = $acme->key_authorization($dns_challenge->{'token'});
+ my $digest = PVE::ACME::encode(sha256($key_auth));
+ my $cmd = &$compose_cmd('pve-setup', $digest, $domain, $alias);
+
+ PVE::Tools::run_command($cmd, outfunc => $outfunc);
+
+ return ($url, $digest, $domain);
+}
+
1;
--
2.20.1
More information about the pve-devel
mailing list