Skip to content

Commit

Permalink
Fixed the error message when the password of a PKCS#12 keystore is mi…
Browse files Browse the repository at this point in the history
…ssing (Fixes #201)
  • Loading branch information
ebourg committed Feb 10, 2024
1 parent bfe4e88 commit 12f77bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions jsign-core/src/main/java/net/jsign/SignerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) + ")";
}
Expand Down
12 changes: 12 additions & 0 deletions jsign-core/src/test/java/net/jsign/SignerHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

0 comments on commit 12f77bb

Please sign in to comment.