private Http01Challenge httpChallenge(Authorization auth) throws AcmeException { // Find a single http-01 challenge Http01Challenge challenge = auth.findChallenge(Http01Challenge.TYPE); if (challenge == null) { throw new AcmeException("Found no " + Http01Challenge.TYPE + " challenge, don't know what to do..."); } // Output the challenge, wait for acknowledge... log.debug("http://{}/.well-known/acme-challenge/{}", auth.getIdentifier().getDomain(), challenge.getToken()); log.debug("Content: {}", challenge.getAuthorization()); return challenge; }
Session session = new Session(letsEncryptUrl); Account account = new AccountBuilder() .agreeToTermsOfService() .useKeyPair(userKeyPair) .addEmail(contact) .create(session); log.info("Registered a new user, URL: {}", account.getLocation()); Order order = account.newOrder().domain(domain).create(); for (Authorization auth : order.getAuthorizations()) { authorize(auth); CSRBuilder csrb = new CSRBuilder(); csrb.addDomain(domain); csrb.setOrganization("Blynk Inc."); csrb.sign(domainKeyPair); order.execute(csrb.getEncoded()); while (order.getStatus() != Status.VALID && attempts-- > 0) { if (order.getStatus() == Status.INVALID) { throw new AcmeException("Order failed... Giving up."); order.update(); Certificate certificate = order.getCertificate();
log.info("Starting authorization for domain {}", auth.getIdentifier().getDomain()); throw new AcmeException("No challenge found"); contentHolder.content = challenge.getAuthorization(); if (challenge.getStatus() == Status.VALID) { return; challenge.trigger(); while (challenge.getStatus() != Status.VALID && attempts-- > 0) { if (challenge.getStatus() == Status.INVALID) { throw new AcmeException("Challenge failed... Giving up."); challenge.update(); if (challenge.getStatus() != Status.VALID) { throw new AcmeException("Failed to pass the challenge for domain " + auth.getIdentifier().getDomain() + ", ... Giving up.");
/** * Creates a new account. * * @param session * {@link Session} to be used for registration * @return {@link Account} referring to the new account */ public Account create(Session session) throws AcmeException { return createLogin(session).getAccount(); }
/** * Adds a domain name to the order. * * @param domain * Name of a domain to be ordered. May be a wildcard domain if supported by * the CA. IDN names are accepted and will be ACE encoded automatically. * @return itself */ public OrderBuilder domain(String domain) { return identifier(Identifier.dns(domain)); }
/** * Gets the {@link Session} this resource is bound with. */ protected Session getSession() { return getLogin().getSession(); }
/** * Creates a builder for a new {@link Order}. * * @return {@link OrderBuilder} object */ public OrderBuilder newOrder() { return new OrderBuilder(getLogin()); }
/** * Revokes this certificate. */ public void revoke() throws AcmeException { revoke(null); }
/** * Modifies the account data of the account. * * @return {@link EditableAccount} where the account can be modified */ public EditableAccount modify() { return new EditableAccount(); }
/** * Returns the error type. */ public URI getType() { return problem.getType(); }
/** * Logs into an existing account. * * @param accountLocation * Location {@link URL} of the account * @param accountKeyPair * Account {@link KeyPair} * @return {@link Login} to this account */ public Login login(URL accountLocation, KeyPair accountKeyPair) { return new Login(accountLocation, accountKeyPair, this); }
protected Account(Login login) { super(login, login.getAccountLocation()); }
/** * Creates a new account. * * @param session * {@link Session} to be used for registration * @return {@link Account} referring to the new account */ public Account create(Session session) throws AcmeException { return createLogin(session).getAccount(); }
/** * Adds a domain name to the order. * * @param domain * Name of a domain to be ordered. May be a wildcard domain if supported by * the CA. IDN names are accepted and will be ACE encoded automatically. * @return itself */ public OrderBuilder domain(String domain) { return identifier(Identifier.dns(domain)); }
/** * Gets the {@link Session} this resource is bound with. */ protected Session getSession() { return getLogin().getSession(); }
/** * Creates a builder for a new {@link Order}. * * @return {@link OrderBuilder} object */ public OrderBuilder newOrder() { return new OrderBuilder(getLogin()); }
/** * Revokes this certificate. */ public void revoke() throws AcmeException { revoke(null); }
/** * Modifies the account data of the account. * * @return {@link EditableAccount} where the account can be modified */ public EditableAccount modify() { return new EditableAccount(); }
/** * Returns the error type. */ public URI getType() { return problem.getType(); }
/** * Logs into an existing account. * * @param accountLocation * Location {@link URL} of the account * @param accountKeyPair * Account {@link KeyPair} * @return {@link Login} to this account */ public Login login(URL accountLocation, KeyPair accountKeyPair) { return new Login(accountLocation, accountKeyPair, this); }