diff --git a/README.md b/README.md index a96b097a..6419722e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ See https://ebourg.github.io/jsign for more information. #### Version 6.1 (in development) * Signing of NuGet packages has been implemented (contributed by Sebastian Stamm) +* The error message displayed when the password of a PKCS#12 keystore is missing has been fixed #### Version 6.0 (2024-01-17) diff --git a/jsign-core/src/main/java/net/jsign/SignerHelper.java b/jsign-core/src/main/java/net/jsign/SignerHelper.java index d4247c94..982ce6a1 100644 --- a/jsign-core/src/main/java/net/jsign/SignerHelper.java +++ b/jsign-core/src/main/java/net/jsign/SignerHelper.java @@ -291,6 +291,8 @@ private AuthenticodeSigner build() throws SignerException { aliases = new LinkedHashSet<>(Collections.list(ks.aliases())); if (aliases.isEmpty()) { message = "No certificate found in the keystore " + (provider != null ? provider.getName() : ksparams.keystore()); + } else if (aliases.contains(alias)) { + message = "The keystore password must be specified"; } else { message += " (available aliases: " + String.join(", ", aliases) + ")"; } diff --git a/jsign-core/src/test/java/net/jsign/SignerHelperTest.java b/jsign-core/src/test/java/net/jsign/SignerHelperTest.java index 759f8cc6..30d65edf 100644 --- a/jsign-core/src/test/java/net/jsign/SignerHelperTest.java +++ b/jsign-core/src/test/java/net/jsign/SignerHelperTest.java @@ -377,4 +377,16 @@ public void testSignWithMismatchedRSAKeys() throws Exception { SignatureAssert.assertSigned(Signable.of(targetFile)); } + + @Test + public void testMissingPKCS12KeyStorePassword() { + SignerHelper signer = new SignerHelper(new StdOutConsole(2), "parameter"); + signer.keystore("target/test-classes/keystores/keystore.p12"); + signer.alias("test"); + try { + signer.sign("target/test-classes/wineyes.exe"); + } catch (SignerException e) { + assertEquals("message", "The keystore password must be specified", e.getMessage()); + } + } }