.useKeyPair(userKeyPair) .addEmail(contact) .create(session); log.info("Registered a new user, URL: {}", account.getLocation());
public CompletableFuture<URL> openAccount(String email, KeyPair accountKeyPair) { try { log.info("open account"); Session session = new Session("acme://letsencrypt.org/staging"); Account account = new AccountBuilder() .addContact("mailto:"+email) .agreeToTermsOfService() .useKeyPair(accountKeyPair) .create(session); URL location = account.getLocation(); log.info("account location="+location); return CompletableFuture.completedFuture(location); } catch (AcmeException e) { throw new RuntimeException(e); } } //TODO: Put the remote request INTO a different pool to not hold up the webserver main
private void login() { KeyPair accountKeyPair = RSATools.createKeyPair(RSACrypt.RSA_CRYPT.loadKeysPemFromString(config.getAccountKeypairPem())); LOGGER.info("Registering account"); try { account = new AccountBuilder() // .addContact("mailto:" + config.getContactEmail()) // .agreeToTermsOfService() // .useKeyPair(accountKeyPair) // .create(session); } catch (AcmeException e) { LOGGER.error("Problem logging in", e); throw new LetsencryptException("Problem logging in", e); } URL accountLocationUrl = account.getLocation(); session.login(accountLocationUrl, accountKeyPair); // Get the location LOGGER.info("AcmeClient location: {}", accountLocationUrl); }
/** * Finds your {@link Account} at the ACME server. It will be found by your user's * public key. If your key is not known to the server yet, a new account will be * created. * <p> * This is a simple way of finding your {@link Account}. A better way is to get the * URL and KeyIdentifier of your new account with {@link Account#getLocation()} * {@link Session#getKeyIdentifier()} and store it somewhere. If you need to get * access to your account later, reconnect to it via * {@link Account#bind(Session, URI)} by using the stored location. * * @param session * {@link Session} to bind with * @return {@link Login} that is connected to your account */ private Account findOrRegisterAccount(Session session, KeyPair accountKey) throws AcmeException { // Ask the user to accept the TOS, if server provides us with a link. URI tos = session.getMetadata().getTermsOfService(); if (tos != null) { acceptAgreement(tos); } Account account = new AccountBuilder() .agreeToTermsOfService() .useKeyPair(accountKey) .create(session); LOG.info("Registered a new user, URL: {}", account.getLocation()); return account; }
final Account account = new AccountBuilder().agreeToTermsOfService().useKeyPair(userKeyPair).create(session); final Order order = account.newOrder().domains(config.getDomains().trim().split(",")).create(); final boolean updated = order.getAuthorizations().stream().map(authorization -> {