File tree 5 files changed +64
-3
lines changed
5 files changed +64
-3
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ See https://ebourg.github.io/jsign for more information.
42
42
43
43
#### Version 4.1 (in development)
44
44
45
+ * The Ant task can now sign multiple files by defining a fileset (contributed by Kyle Berezin)
45
46
* Fixed the _ "Map failed"_ OutOfMemoryError when signing large MSI files
46
47
47
48
#### Version 4.0 (2021-08-09)
Original file line number Diff line number Diff line change 5
5
- Support private keys exported with PKCS#8
6
6
- Detect the type of the keystore automatically (guess from the extension and try all the other types as a fallback)
7
7
- Support unauthenticated blobs
8
- - Sign multiple files (fileset)
9
8
- Support generating MsiDigitalSignatureEx entries when signing MSI files (requires access to the streams metadata in POI)
10
9
- load password from the environment (CLI syntax: env:VARIABLE_NAME)
11
10
- AWS KMS integration
Original file line number Diff line number Diff line change 20
20
21
21
import org .apache .tools .ant .BuildException ;
22
22
import org .apache .tools .ant .Task ;
23
+ import org .apache .tools .ant .types .FileSet ;
23
24
24
25
/**
25
26
* Ant task for signing files with Authenticode.
@@ -32,6 +33,9 @@ public class JsignTask extends Task {
32
33
/** The file to be signed. */
33
34
private File file ;
34
35
36
+ /** The set of files to be signed. */
37
+ private FileSet fileset ;
38
+
35
39
/** The program name embedded in the signature. */
36
40
private String name ;
37
41
@@ -87,6 +91,10 @@ public void setFile(File file) {
87
91
this .file = file ;
88
92
}
89
93
94
+ public void addFileset (FileSet fileset ) {
95
+ this .fileset = fileset ;
96
+ }
97
+
90
98
public void setName (String name ) {
91
99
this .name = name ;
92
100
}
@@ -177,8 +185,14 @@ public void execute() throws BuildException {
177
185
helper .replace (replace );
178
186
helper .encoding (encoding );
179
187
helper .detached (detached );
180
-
181
- helper .sign (file );
188
+
189
+ if (fileset != null ) {
190
+ for (String fileElement : fileset .getDirectoryScanner ().getIncludedFiles ()) {
191
+ helper .sign (new File (fileset .getDir (), fileElement ));
192
+ }
193
+ } else {
194
+ helper .sign (file );
195
+ }
182
196
} catch (Exception e ) {
183
197
throw new BuildException (e .getMessage (), e , getLocation ());
184
198
}
Original file line number Diff line number Diff line change @@ -187,6 +187,37 @@ public void testSigning() throws Exception {
187
187
}
188
188
}
189
189
190
+ @ Test
191
+ public void testSigningMultipleFiles () throws Exception {
192
+ FileUtils .copyFile (sourceFile , targetFile );
193
+
194
+ project .executeTarget ("signing-multiple-files" );
195
+
196
+ File targetFile2 = new File ("target/test-classes/wineyes-multiple-files-test.exe" );
197
+
198
+ assertTrue ("The file " + targetFile + " wasn't changed" , SOURCE_FILE_CRC32 != FileUtils .checksumCRC32 (targetFile ));
199
+ assertTrue ("The file " + targetFile2 + " wasn't changed" , SOURCE_FILE_CRC32 != FileUtils .checksumCRC32 (targetFile2 ));
200
+
201
+ try (PEFile peFile = new PEFile (targetFile )) {
202
+ List <CMSSignedData > signatures = peFile .getSignatures ();
203
+ assertNotNull (signatures );
204
+ assertEquals (1 , signatures .size ());
205
+
206
+ CMSSignedData signature = signatures .get (0 );
207
+
208
+ assertNotNull (signature );
209
+ }
210
+ try (PEFile peFile = new PEFile (targetFile2 )) {
211
+ List <CMSSignedData > signatures = peFile .getSignatures ();
212
+ assertNotNull (signatures );
213
+ assertEquals (1 , signatures .size ());
214
+
215
+ CMSSignedData signature = signatures .get (0 );
216
+
217
+ assertNotNull (signature );
218
+ }
219
+ }
220
+
190
221
@ Test
191
222
public void testSigningPowerShell () throws Exception {
192
223
File sourceFile = new File ("target/test-classes/hello-world.ps1" );
Original file line number Diff line number Diff line change 88
88
keypass =" ${keypass}" />
89
89
</target >
90
90
91
+ <target name =" signing-multiple-files" >
92
+ <copy file =" wineyes.exe" tofile =" wineyes-multiple-files-test.exe" overwrite =" true" />
93
+ <jsign name =" WinEyes"
94
+ url =" http://www.steelblue.com/WinEyes"
95
+ alg =" SHA-1"
96
+ keystore =" ${keystore}"
97
+ alias =" ${alias}"
98
+ keypass =" ${keypass}"
99
+ tsmode =" authenticode" >
100
+ <fileset dir =" ./" >
101
+ <include name =" wineyes-multiple-files-test.exe" />
102
+ <include name =" wineyes-signed-with-ant.exe" />
103
+ </fileset >
104
+ </jsign >
105
+ </target >
106
+
91
107
<target name =" signing-powershell" >
92
108
<jsign file =" hello-world-signed-with-ant.ps1"
93
109
alg =" SHA-1"
You can’t perform that action at this time.
0 commit comments