Skip to content

Commit

Permalink
Fix chain and fullchain certificates; Update acme to 2.7; Gradle to 5…
Browse files Browse the repository at this point in the history
….5.1; bouncycastle to 1.62
  • Loading branch information
porunov committed Aug 2, 2019
1 parent db5b572 commit c43a416
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ targetCompatibility = 1.8

dependencies {
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile group: 'org.shredzone.acme4j', name: 'acme4j-client', version: '2.2'
compile group: 'org.shredzone.acme4j', name: 'acme4j-utils', version: '2.2'
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.60'
compile group: 'org.shredzone.acme4j', name: 'acme4j-client', version: '2.7'
compile group: 'org.shredzone.acme4j', name: 'acme4j-utils', version: '2.7'
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.62'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
compile group: 'com.beust', name: 'jcommander', version: '1.72'
}
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Fri Aug 02 02:54:54 EEST 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void writeChallengeByAuthorization(AuthorizationManager authorizationManagement)
if (getParameters().isOneDirForWellKnown()) {
path = Paths.get(getParameters().getWellKnownDir(), http01Challenge.getToken()).toString();
} else {
String subdir = authorizationManagement.getAuthorization().getDomain()+
String subdir = authorizationManagement.getAuthorization().getIdentifier().getDomain()+
returnIfWildcard(authorizationManagement.getAuthorization());
path = Paths.get(getParameters().getWellKnownDir(), subdir).toString();
IOManager.createDirectories(path);
Expand All @@ -140,7 +140,7 @@ void writeChallengeByAuthorization(AuthorizationManager authorizationManagement)
String fileSuffix = "_dns_digest"+returnIfWildcard(authorization);
IOManager.writeString(
Paths.get(getParameters().getDnsDigestDir(),
authorizationManagement.getAuthorization().getDomain() + fileSuffix).toString(),
authorizationManagement.getAuthorization().getIdentifier().getDomain() + fileSuffix).toString(),
dns01Challenge.getDigest()
);
break;
Expand Down Expand Up @@ -256,7 +256,7 @@ List<Certificate> getNotExpiredCertificates() {
}

String getDomain(Authorization authorization){
String domain = authorization.getDomain();
String domain = authorization.getIdentifier().getDomain();
if(authorization.isWildcard() && !domain.startsWith("*.")){
domain = "*."+domain;
}
Expand Down
30 changes: 19 additions & 11 deletions src/main/java/com/jblur/acme_client/manager/CertificateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.net.URL;
import java.security.KeyPair;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.List;

public class CertificateManager {

Expand All @@ -34,20 +36,26 @@ public X509Certificate downloadCertificate() {
}

public X509Certificate[] downloadCertificateChain() {
return this.certificate.getCertificateChain().toArray(new X509Certificate[]{});

X509Certificate[] fullChain = downloadFullChainCertificate();

if(fullChain.length==0){
return fullChain;
}

if (fullChain.length==1){
return new X509Certificate[0];
}

X509Certificate[] chain = new X509Certificate[fullChain.length-1];

System.arraycopy(fullChain, 1, chain, 0, fullChain.length-1);

return chain;
}

public X509Certificate[] downloadFullChainCertificate() {
X509Certificate cert = downloadCertificate();
X509Certificate[] chain = downloadCertificateChain();
X509Certificate[] fullChain = new X509Certificate[chain.length + 1];
fullChain[0] = cert;
int i = 1;
for (X509Certificate x509Certificate : chain) {
fullChain[i] = x509Certificate;
i++;
}
return fullChain;
return this.certificate.getCertificateChain().toArray(new X509Certificate[]{});
}

public void revokeCertificate() throws AcmeException {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=Porunov Java ACME Client (PJAC) v3.0.0
version=Porunov Java ACME Client (PJAC) v3.0.1

0 comments on commit c43a416

Please sign in to comment.