Skip to content

Commit

Permalink
Support signing by jsign without google cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Schwertfeger committed Jan 20, 2025
1 parent 6f12925 commit 3f498eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,22 @@ public static Builder builder() {
@Override
public Path sign(Path file) {
try {
KeyStore keystore =
new KeyStoreBuilder()
.storetype(configuration().getStoreType())
.keystore(configuration().getKeystore())
.storepass(googleAccessToken())
.certfile(configuration().getCertificateChain().toFile())
.build();
KeyStoreBuilder keyStoreBuilder = new KeyStoreBuilder()
.storetype(configuration().getStoreType())
.keystore(configuration().getKeystore());
if (kmsCredentials!=null) {
keyStoreBuilder.storepass(googleAccessToken());
} else if (configuration().getStorePass() != null) {
keyStoreBuilder.storepass(configuration().getStorePass());
}
try {
if (configuration().getCertificateChain() != null) {
keyStoreBuilder.certfile(configuration().getCertificateChain().toFile());
}
} catch(IllegalArgumentException e){
// Ignore missing certficate chain;could be stored in keystore
}
KeyStore keystore =keyStoreBuilder.build();

AuthenticodeSigner signer =
new AuthenticodeSigner(keystore, configuration().getKeyAlias(), null)
Expand Down Expand Up @@ -105,7 +114,7 @@ private String googleAccessToken() {
throw new RuntimeException(ex);
}
} else {
throw new RuntimeException("Tried to retrieve a Google Cloud Access Token while no credentials have been provided");
return "NONE";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class JSignerProperties {
private static final String JSIGN_DESCRIPTION = "windows.jsign.description";

private static final String JSIGN_STORETYPE = "windows.jsign.storetype";
private static final String JSIGN_STOREPASS = "windows.jsign.storepass";
private static final String JSIGN_KEYSTORE = "windows.jsign.keystore";
private static final String JSIGN_KEY_ALIAS = "windows.jsign.keyalias";
private static final String JSIGN_CERTCHAIN = "windows.jsign.certchain";
Expand Down Expand Up @@ -67,6 +68,10 @@ public String getStoreType() {
return propertiesReader.getString(JSIGN_STORETYPE);
}

public String getStorePass() {
return propertiesReader.getString(JSIGN_STOREPASS);
}

public String getKeystore() {
return propertiesReader.getString(JSIGN_KEYSTORE);
}
Expand Down

0 comments on commit 3f498eb

Please sign in to comment.