Skip to content

Commit bc1bedd

Browse files
committed
Adjusted the SignServer error messages
1 parent 863e958 commit bc1bedd

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

jsign-crypto/src/main/java/net/jsign/KeyStoreType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,11 @@ Provider getProvider(KeyStoreBuilder params) {
550550
SIGNSERVER(false, false, false) {
551551
@Override
552552
void validate(KeyStoreBuilder params) {
553+
if (params.keystore() == null) {
554+
throw new IllegalArgumentException("keystore " + params.parameterName() + " must specify the SignServer API endpoint (e.g. https://example.com/signserver/)");
555+
}
553556
if (params.storepass() != null && params.storepass().split("\\|").length > 2) {
554-
throw new IllegalArgumentException("storepass " + params.parameterName() + " must specify the SignServer username/password or the path to the keystore containing the TLS client certificate: <username>|<password>, <certificate>");
557+
throw new IllegalArgumentException("storepass " + params.parameterName() + " must specify the SignServer username/password or the path to the keystore containing the TLS client certificate: <username>|<password> or <certificate>");
555558
}
556559
}
557560

jsign-crypto/src/main/java/net/jsign/jca/SignServerSigningService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import net.jsign.DigestAlgorithm;
3838

3939
import static java.nio.charset.StandardCharsets.UTF_8;
40-
import static java.util.Objects.requireNonNull;
4140

4241
/**
4342
* Signing service using the Keyfactor SignServer REST API.
@@ -58,9 +57,7 @@ public class SignServerSigningService implements SigningService {
5857
* @param credentials the SignServer credentials
5958
*/
6059
public SignServerSigningService(String endpoint, SignServerCredentials credentials) {
61-
this.client = new RESTClient(
62-
requireNonNull(endpoint, "You need to provide the SignServer endpoint URL as keystore parameter")
63-
+ (endpoint.endsWith("/") ? "" : "/"))
60+
this.client = new RESTClient(endpoint)
6461
.authentication(conn -> {
6562
if (conn instanceof HttpsURLConnection && credentials.keystore != null) {
6663
try {

jsign-crypto/src/test/java/net/jsign/KeyStoreBuilderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@ public void testBuildGaraSign() throws Exception {
309309
public void testBuildSignServer() throws Exception {
310310
KeyStoreBuilder builder = new KeyStoreBuilder().storetype(SIGNSERVER);
311311

312-
Exception e = assertThrows(NullPointerException.class, builder::build);
313-
assertEquals("message", "You need to provide the SignServer endpoint URL as keystore parameter", e.getMessage());
312+
Exception e = assertThrows(IllegalArgumentException.class, builder::build);
313+
assertEquals("message", "keystore parameter must specify the SignServer API endpoint (e.g. https://example.com/signserver/)", e.getMessage());
314314

315315
builder.keystore("https://example.com/signserver");
316316

317317
builder.storepass("username|password|certificate.p12");
318318

319319
e = assertThrows(IllegalArgumentException.class, builder::build);
320-
assertEquals("message", "storepass parameter must specify the SignServer username/password or the path to the keystore containing the TLS client certificate: <username>|<password>, <certificate>", e.getMessage());
320+
assertEquals("message", "storepass parameter must specify the SignServer username/password or the path to the keystore containing the TLS client certificate: <username>|<password> or <certificate>", e.getMessage());
321321

322322
builder.storepass("username|password");
323323

0 commit comments

Comments
 (0)