Improve error messages

This commit is contained in:
Přemysl Eric Janouch 2017-05-16 20:47:12 +02:00
parent 952d12825c
commit d1f7b80ca9
Signed by: p
GPG Key ID: B715679E3A361BE6

View File

@ -85,7 +85,7 @@ die 'cannot parse CSR' if $?;
my @domains;
push @domains, $1 if $csr =~ /Subject:.*? CN *= *([^\s,;\/]+)/;
# FIXME: this may not parse correctly either, try it out
# FIXME: this may not parse correctly anymore, try it out
push @domains, map { substr $_, 4 } grep { /^DNS:/ } split(/, /)
for $csr =~ /X509v3 Subject Alternative Name: \n +([^\n]+)\n/g;
@ -121,7 +121,7 @@ for my $domain (@domains) {
eval {
my $url = "http://$domain/.well-known/acme-challenge/$token";
my ($code, $result) = get $url;
die "checking challenge failed: $code" if $code != 200;
die "checking $url failed: $code" if $code != 200;
die 'challenge contents differ' if $result ne $key_auth;
# Submit the challenge and wait for the verification to finish
@ -129,18 +129,18 @@ eval {
resource => 'challenge',
keyAuthorization => $key_auth
});
die "checking challenge failed: $code" if $code != 202;
die "challenge submission failed: $code" if $code != 202;
while (1) {
($code, $result) = get $challenge->{uri};
die "verifying challenge failed: $code" if $code >= 400;
die "challenge verification failed: $code" if $code >= 400;
my $status = $json->decode($result);
if ($status->{status} eq 'valid') {
last;
} elsif ($status->{status} eq 'pending') {
sleep 1;
} else {
die "verifying challenge failed: $status";
die "challenge verification failed: $result";
}
}
};