From 110180e0f49aeb8222ee9b04a40389252fa1229f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maltoni?= Date: Fri, 18 Oct 2024 22:45:06 +0200 Subject: [PATCH] build: upgrade ACME4j --- carapace-server/pom.xml | 11 ----------- .../server/certificates/ACMEClient.java | 19 +++++++------------ pom.xml | 2 +- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/carapace-server/pom.xml b/carapace-server/pom.xml index f495085a5..3b343c07b 100644 --- a/carapace-server/pom.xml +++ b/carapace-server/pom.xml @@ -43,17 +43,6 @@ - - org.shredzone.acme4j - acme4j-utils - ${libs.acme4j} - - - org.bouncycastle - * - - - org.bouncycastle bcpkix-jdk18on diff --git a/carapace-server/src/main/java/org/carapaceproxy/server/certificates/ACMEClient.java b/carapace-server/src/main/java/org/carapaceproxy/server/certificates/ACMEClient.java index 03781d7c1..5cebe3e9c 100644 --- a/carapace-server/src/main/java/org/carapaceproxy/server/certificates/ACMEClient.java +++ b/carapace-server/src/main/java/org/carapaceproxy/server/certificates/ACMEClient.java @@ -66,10 +66,6 @@ public class ACMEClient { private final boolean testingModeOn; private final KeyPair userKey; - public enum ChallengeType { - HTTP - } - public ACMEClient(KeyPair userKey, boolean testingMode) { Security.addProvider(new BouncyCastleProvider()); this.userKey = userKey; @@ -140,10 +136,9 @@ public Map getChallengesForOrder(Order order) throws AcmeExce * @return {@link Http01Challenge} to verify */ private Http01Challenge httpChallenge(Authorization auth) throws AcmeException { - Http01Challenge challenge = auth.findChallenge(Http01Challenge.TYPE); - if (challenge == null) { - throw new AcmeException("Found no " + Http01Challenge.TYPE + " challenge, don't know what to do..."); - } + Http01Challenge challenge = auth.findChallenge(Http01Challenge.TYPE) + .map(Http01Challenge.class::cast) + .orElseThrow(() -> new AcmeException("Found no " + Http01Challenge.TYPE + " challenge, don't know what to do...")); LOG.debug("It must be reachable at: http://{}/.well-known/acme-challenge/{}", auth.getIdentifier().getDomain(), challenge.getToken() ); @@ -161,10 +156,10 @@ private Http01Challenge httpChallenge(Authorization auth) throws AcmeException { * @throws org.shredzone.acme4j.exception.AcmeException */ public Challenge dnsChallenge(Authorization auth) throws AcmeException { - Dns01Challenge challenge = auth.findChallenge(Dns01Challenge.TYPE); - if (challenge == null) { - throw new AcmeException("Found no " + Dns01Challenge.TYPE + " challenge, don't know what to do..."); - } + Dns01Challenge challenge = auth + .findChallenge(Dns01Challenge.TYPE) + .map(Dns01Challenge.class::cast) + .orElseThrow(() -> new AcmeException("Found no " + Dns01Challenge.TYPE + " challenge, don't know what to do...")); LOG.info("DNS-challenge _acme-challenge.{}. to save as TXT-record with content {}", auth.getIdentifier().getDomain(), challenge.getDigest()); return challenge; } diff --git a/pom.xml b/pom.xml index 2e411b97f..6da9ad6fb 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ 2023.0.11 4.1.114.Final - 2.12 + 3.4.0 1.78.1 2.17.113 3.0.5