Wait for the order to become valid

pull/61/head
Richard Körber 2018-03-13 22:13:46 +01:00
parent 04d00fc2c5
commit 3e1cb01fa0
No known key found for this signature in database
GPG Key ID: AAB9FD19C78AA3E0
1 changed files with 23 additions and 1 deletions

View File

@ -104,8 +104,30 @@ public class ClientTest {
csrb.write(out);
}
// Get the certificate
// Order the certificate
order.execute(csrb.getEncoded());
// Wait for the order to complete
try {
int attempts = 10;
while (order.getStatus() != Status.VALID && attempts-- > 0) {
// Did the order fail?
if (order.getStatus() == Status.INVALID) {
throw new AcmeException("Order failed... Giving up.");
}
// Wait for a few seconds
Thread.sleep(3000L);
// Then update the status
order.update();
}
} catch (InterruptedException ex) {
LOG.error("interrupted", ex);
Thread.currentThread().interrupt();
}
// Get the certificate
Certificate certificate = order.getCertificate();
LOG.info("Success! The certificate for domains " + domains + " has been generated!");