Skip to content

Commit 0f9083e

Browse files
committed
Refine ACME exception handling
- Simplify createBadNonceException() to accept a single detail string. - Stop exception handling after sending an error when nonce creation fails. Signed-off-by: andrew yuan <mingxuan199404@gmail.com>
1 parent 17c4db3 commit 0f9083e

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

base/acme/src/main/java/org/dogtagpki/acme/server/ACMEEngine.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,14 +602,14 @@ public void validateNonce(String value) throws Exception {
602602
}
603603

604604
if (nonce == null) {
605-
throw createBadNonceException("Invalid nonce: ",value);
605+
throw createBadNonceException("Invalid nonce: " + value);
606606
}
607607

608608
long currentTime = System.currentTimeMillis();
609609
long expirationTime = nonce.getExpirationTime().getTime();
610610

611611
if (expirationTime <= currentTime) {
612-
throw createBadNonceException("Expired nonce: ",value);
612+
throw createBadNonceException("Expired nonce: "+ value);
613613
}
614614

615615
logger.info("Valid nonce: " + value);
@@ -793,10 +793,10 @@ public Exception createMalformedException(String desc) {
793793
throw new ACMEException(HttpServletResponse.SC_BAD_REQUEST, error);
794794
}
795795

796-
public Exception createBadNonceException(String desc, String value) {
796+
public Exception createBadNonceException(String detail) {
797797
ACMEError error = new ACMEError();
798798
error.setType("urn:ietf:params:acme:error:badNonce");
799-
error.setDetail(desc + value);
799+
error.setDetail(detail);
800800

801801
throw new ACMEException(HttpServletResponse.SC_BAD_REQUEST,error);
802802
}

base/acme/src/main/java/org/dogtagpki/acme/server/ACMEServlet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ protected void handlePKIException(
5757
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
5858
"Unable to generate replacement nonce"
5959
);
60+
return;
6061
}
6162

6263
super.handlePKIException(request, response, exception);

0 commit comments

Comments
 (0)