Better error output

This commit is contained in:
Přemysl Eric Janouch 2017-06-07 05:47:22 +02:00
parent 92c81596c8
commit b09c0c23ee
Signed by: p
GPG Key ID: B715679E3A361BE6

View File

@ -97,7 +97,7 @@ my ($code, $result, $headers) = get "$ca/terms";
? $headers->{Location}
: 'https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf'
});
die "cannot register: $code" if $code != 201 && $code != 409;
die "cannot register: $code\n$result" if $code != 201 && $code != 409;
# Check if the file is really there, submit an HTTP challenge and wait
sub verify_http {
@ -109,11 +109,11 @@ sub verify_http {
($code, $result) = send_signed($challenge_uri, {
resource => 'challenge', keyAuthorization => $key_auth
});
die "challenge submission failed: $code" if $code != 202;
die "challenge submission failed: $code\n$result" if $code != 202;
while (1) {
($code, $result) = get $challenge_uri;
die "challenge verification failed: $code" if $code >= 400;
die "challenge verification failed: $code\n$result" if $code >= 400;
my $status = $json->decode($result);
if ($status->{status} eq 'valid') {
last;
@ -130,7 +130,7 @@ for my $domain (@domains) {
resource => 'new-authz',
identifier => { type => 'dns', value => $domain }
});
die "cannot request challenge: $code" if $code != 201;
die "cannot request challenge: $code\n$result" if $code != 201;
my ($challenge) = grep { $_->{type} eq 'http-01' }
@{$json->decode($result)->{challenges}};
@ -155,7 +155,7 @@ die 'cannot convert CSR' if $?;
($code, $result) = send_signed("$ca/acme/new-cert", {
resource => 'new-cert', csr => b64 $der
});
die "cannot sign certificate: $code" if $code != 201;
die "cannot sign certificate: $code\n$result" if $code != 201;
my $pem = join("\n", unpack '(A64)*', encode_base64($result, ''));
print "-----BEGIN CERTIFICATE-----\n$pem\n-----END CERTIFICATE-----\n";