1 package PVE
::ACME
::DNSChallenge
;
6 use Digest
::SHA
qw(sha256);
9 use base
qw(PVE::ACME::Challenge);
11 my $ACME_PATH = '/usr/share/proxmox-acme/proxmox-acme';
13 sub supported_challenge_types
{
122 sub get_supported_plugins
{
123 return $plugin_names;
129 description
=> "API plugin name",
131 enum
=> $plugin_names,
135 description
=> 'DNS plugin data.',
143 data
=> { optional
=> 1 },
144 nodes
=> { optional
=> 1 },
145 disable
=> { optional
=> 1 },
149 my $proxmox_acme_command = sub {
150 my ($self, $acme, $auth, $data, $action) = @_;
152 die "No plugin data for DNSChallenge\n" if !defined($data->{plugin
});
154 my $alias = $data->{alias
};
155 my $domain = $auth->{identifier
}->{value
};
157 my $challenge = $self->extract_challenge($auth->{challenges
});
158 my $key_auth = $acme->key_authorization($challenge->{token
});
160 my $txtvalue = PVE
::ACME
::encode
(sha256
($key_auth));
161 my $dnsplugin = $data->{plugin
}->{api
};
162 my $plugin_conf_string = $data->{plugin
}->{data
};
164 # for security reasons, we execute the command as nobody
165 # we can't verify that the code of the DNSPlugins are harmless.
166 my $cmd = ["setpriv", "--reuid", "nobody", "--regid", "nogroup", "--clear-groups", "--reset-env", "--"];
168 # The order of the parameters passed to proxmox-acme is important
169 # proxmox-acme <setup|teardown> $plugin <$domain|$alias> $txtvalue [$plugin_conf_string]
170 push @$cmd, "/bin/bash", $ACME_PATH, $action, $dnsplugin;
176 my $input = "$txtvalue\n";
177 $input .= "$plugin_conf_string\n" if $plugin_conf_string;
179 PVE
::Tools
::run_command
($cmd, input
=> $input);
181 $data->{url
} = $challenge->{url
};
187 my ($self, $acme, $auth, $data) = @_;
189 my $domain = $proxmox_acme_command->($self, $acme, $auth, $data, 'setup');
190 print "Add TXT record: _acme-challenge.$domain\n";
194 my ($self, $acme, $auth, $data) = @_;
196 my $domain = $proxmox_acme_command->($self, $acme, $auth, $data, 'teardown');
197 print "Remove TXT record: _acme-challenge.$domain\n";