Update AcmeClient to fix certificate renewal #9

Merged
NorbiPeti merged 2 commits from dev into master 2018-07-04 18:36:49 +00:00
3 changed files with 19 additions and 28 deletions
Showing only changes of commit cca6235179 - Show all commits

10
pom.xml
View file

@ -45,11 +45,6 @@
<!-- <artifactSet> <includes> <include>org.shredzone.acme4j:acme4j-client</include> <!-- <artifactSet> <includes> <include>org.shredzone.acme4j:acme4j-client</include>
<include>org.shredzone.acme4j:acme4j-utils</include> <include>org.bouncycastle:bcprov-jdk15on</include> <include>org.shredzone.acme4j:acme4j-utils</include> <include>org.bouncycastle:bcprov-jdk15on</include>
</includes> </artifactSet> --> </includes> </artifactSet> -->
<pluginExecution>
<action>
<execute />
</action>
</pluginExecution>
<filters> <filters>
<filter> <filter>
<artifact>*:*</artifact> <artifact>*:*</artifact>
@ -126,15 +121,16 @@
<version>master-SNAPSHOT</version> <version>master-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.shredzone.acme4j/acme4j-client -->
<dependency> <dependency>
<groupId>org.shredzone.acme4j</groupId> <groupId>org.shredzone.acme4j</groupId>
<artifactId>acme4j-client</artifactId> <artifactId>acme4j-client</artifactId>
<version>0.10</version> <version>2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.shredzone.acme4j</groupId> <groupId>org.shredzone.acme4j</groupId>
<artifactId>acme4j-utils</artifactId> <artifactId>acme4j-utils</artifactId>
<version>0.10</version> <version>2.1</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on --> <!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
<dependency> <dependency>

View file

@ -13,23 +13,14 @@
*/ //Modified */ //Modified
package buttondevteam.website; package buttondevteam.website;
import java.io.BufferedReader; import buttondevteam.lib.TBMCCoreAPI;
import java.io.File; import buttondevteam.website.page.AcmeChallengePage;
import java.io.FileReader; import org.shredzone.acme4j.Authorization;
import java.io.FileWriter; import org.shredzone.acme4j.Certificate;
import java.io.IOException; import org.shredzone.acme4j.Session;
import java.io.InputStreamReader; import org.shredzone.acme4j.Status;
import java.io.Writer;
import java.net.URI;
import java.security.KeyPair;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Collection;
import org.shredzone.acme4j.*;
import org.shredzone.acme4j.challenge.Challenge; import org.shredzone.acme4j.challenge.Challenge;
import org.shredzone.acme4j.challenge.Http01Challenge; import org.shredzone.acme4j.challenge.Http01Challenge;
import org.shredzone.acme4j.exception.AcmeConflictException;
import org.shredzone.acme4j.exception.AcmeException; import org.shredzone.acme4j.exception.AcmeException;
import org.shredzone.acme4j.util.CSRBuilder; import org.shredzone.acme4j.util.CSRBuilder;
import org.shredzone.acme4j.util.CertificateUtils; import org.shredzone.acme4j.util.CertificateUtils;
@ -37,8 +28,12 @@ import org.shredzone.acme4j.util.KeyPairUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import buttondevteam.lib.TBMCCoreAPI; import java.io.*;
import buttondevteam.website.page.AcmeChallengePage; import java.net.URI;
import java.security.KeyPair;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Collection;
/** /**
* A simple client test tool. * A simple client test tool.
@ -73,12 +68,11 @@ public class AcmeClient {
// Load the user key file. If there is no key file, create a new one. // Load the user key file. If there is no key file, create a new one.
// Keep this key pair in a safe place! In a production environment, you will not be // Keep this key pair in a safe place! In a production environment, you will not be
// able to access your account again if you should lose the key pair. // able to access your account again if you should lose the key pair.
KeyPair userKeyPair = loadOrCreateKeyPair(USER_KEY_FILE); KeyPair userKeyPair = loadOrCreateKeyPair(USER_KEY_FILE); //TODO: Migrate to new version
// Create a session for Let's Encrypt. // Create a session for Let's Encrypt.
// Use "acme://letsencrypt.org" for production server // Use "acme://letsencrypt.org" for production server
Session session = new Session("acme://letsencrypt.org" + (TBMCCoreAPI.IsTestServer() ? "/staging" : ""), Session session = new Session("acme://letsencrypt.org" + (TBMCCoreAPI.IsTestServer() ? "/staging" : ""));
userKeyPair);
// Get the Registration to the account. // Get the Registration to the account.
// If there is no account yet, create a new one. // If there is no account yet, create a new one.

View file

@ -132,7 +132,8 @@ public class ButtonWebsiteModule extends JavaPlugin {
} }
}); });
final Calendar calendar = Calendar.getInstance(); final Calendar calendar = Calendar.getInstance();
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week //if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week
if (true) { //TODO: TMP
Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
AcmeClient.main("server.figytuna.com"); // Task is running async so we don't need an extra thread AcmeClient.main("server.figytuna.com"); // Task is running async so we don't need an extra thread
} }