From 968c5f4bb6f6d923b306498dee2c21c418326513 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Thu, 30 Jun 2016 19:11:47 +0200 Subject: More useful message upon Validation Challenge failure. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Format the problem document if the JSON has an “error” key. Cf. section 7 “Identifier Validation Challenges”. --- client | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client b/client index 2566c9b..46f388f 100755 --- a/client +++ b/client @@ -284,10 +284,17 @@ elsif ($COMMAND eq 'new-cert') { keyAuthorization => $keyAuthorization }); # wait until the status become 'valid' - for ( my $i = 0, my $status; - $status = request_json_decode($r)->{status} // 'pending', + for ( my $i = 0, my $content, my $status; + $content = request_json_decode($r), + $status = $content->{status} // 'pending', $status ne 'valid'; $r = request('GET' => $challenge->{uri}), $i++ ) { + if (defined (my $problem = $content->{error})) { # problem document (RFC 7807) + my $msg = $problem->{status}; + $msg .= " " .$problem->{title} if defined $problem->{title}; + $msg .= " (".$problem->{detail}.")" if defined $problem->{detail}; + die $msg, "\n"; + } die "Error: Invalid challenge for $domain (status: ".$status.")\n" if $status ne 'pending'; die "Timeout exceeded while waiting for challenge to pass ($domain)\n" if $i >= ($CONFIG->{timeout} // 10); -- cgit v1.2.3