diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/AccountBuilder.java b/acme4j-client/src/main/java/org/shredzone/acme4j/AccountBuilder.java index 4a3d630e..05dec0d1 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/AccountBuilder.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/AccountBuilder.java @@ -143,7 +143,7 @@ public class AccountBuilder { } conn.sendSignedRequest(resourceUrl, claims, session, true); - conn.accept(HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_CREATED); + int resp = conn.accept(HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_CREATED); URL location = conn.getLocation(); @@ -151,7 +151,10 @@ public class AccountBuilder { if (keyIdentifier != null) { session.setKeyIdentifier(keyIdentifier); } - account.unmarshal(conn.readJsonResponse()); + + if (resp == HttpURLConnection.HTTP_CREATED) { + account.unmarshal(conn.readJsonResponse()); + } return account; } }