Search in sources :

Example 1 with Challenge

use of org.shredzone.acme4j.challenge.Challenge in project meecrowave by apache.

the class LetsEncryptReloadLifecycle method authorize.

private boolean authorize(final Authorization authorization) throws AcmeException {
    final Challenge challenge = httpChallenge(authorization);
    if (challenge == null) {
        throw new AcmeException("HTTP challenge is null");
    }
    if (challenge.getStatus() == Status.VALID) {
        return false;
    }
    challenge.trigger();
    try {
        int attempts = config.getRetryCount();
        while (challenge.getStatus() != Status.VALID && attempts-- > 0) {
            if (challenge.getStatus() == Status.INVALID) {
                throw new AcmeException("Invalid challenge status, exiting refresh iteration");
            }
            Thread.sleep(config.getRetryTimeoutMs());
            challenge.update();
        }
    } catch (final InterruptedException ex) {
        Thread.currentThread().interrupt();
    }
    if (challenge.getStatus() != Status.VALID) {
        throw new AcmeException("Challenge for domain " + authorization.getIdentifier() + ", is invalid, exiting iteration");
    }
    return true;
}
Also used : AcmeException(org.shredzone.acme4j.exception.AcmeException) Http01Challenge(org.shredzone.acme4j.challenge.Http01Challenge) Challenge(org.shredzone.acme4j.challenge.Challenge)

Aggregations

Challenge (org.shredzone.acme4j.challenge.Challenge)1 Http01Challenge (org.shredzone.acme4j.challenge.Http01Challenge)1 AcmeException (org.shredzone.acme4j.exception.AcmeException)1