forked from macagua/example.java.helloworld
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
60 lines (52 loc) · 1.47 KB
/
makefile
File metadata and controls
60 lines (52 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
all: signed-HelloWorld.jar public.cer
HelloWorld/Main.class: HelloWorld/Main.java
# 1 - compile
javac HelloWorld/Main.java
HelloWorld.jar: Manifest.txt HelloWorld/Main.class
# 2 - bundle into jar
jar cfme HelloWorld.jar Manifest.txt HelloWorld.Main HelloWorld/Main.class
keystore.jks:
# 3 - create a keystore
keytool -genkeypair \
-alias signFiles \
-validity 300 \
-keystore keystore.jks
signed-HelloWorld.jar: HelloWorld.jar keystore.jks
# 4 - sign the jar
jarsigner -signedjar \
signed-HelloWorld.jar HelloWorld.jar signFiles \
-tsa http://sha256timestamp.ws.symantec.com/sha256/timestamp \
-keystore keystore.jks
public.cer: keystore.jks
# 5 - export the public certificate
keytool -export -keystore keystore.jks -alias signFiles -file public.cer
# commands to clean, and check results (run the jar and verify etc)
clean:
rm *.jar
rm HelloWorld/*.class
rm *.jks
rm *.cer
run-class:
java -cp . HelloWorld.Main
run-jar:
java -jar HelloWorld.jar
verify: all
# remove tmp keystore if one already exists
- rm tmp-keystore.jks
# create a new keystore
keytool -genkeypair \
-dname "cn=Unknown, ou=Unknown, o=Unknown, c=BE" \
-alias tmp \
-keypass tmptmp \
-storepass tmptmp \
-validity 180 \
-keystore tmp-keystore.jks
# import public certificate
keytool -importcert \
-file public.cer \
-storepass tmptmp \
-noprompt \
-keystore tmp-keystore.jks
# verify the signed jar file
jarsigner -verify signed-HelloWorld.jar \
-keystore tmp-keystore.jks