-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore_jceks.bat
34 lines (28 loc) · 2.25 KB
/
store_jceks.bat
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
@echo off
del /F /Q "server.jceks"
del /F /Q "martim.jceks"
del /F /Q "daniel.jceks"
del /F /Q "joao.jceks"
del /F /Q "truststore.jceks"
del /F /Q "martim.cer"
del /F /Q "daniel.cer"
del /F /Q "joao.cer"
del /F /Q "server.cer"
set /p password="Enter a password for all keystores: "
echo Creating server keystore...
keytool -genkey -alias myserver -keyalg RSA -keysize 2048 -keystore server.jceks -storetype JCEKS -storepass %password% -keypass %password% -noprompt -dname "CN=myserver, OU=OrgUnit, O=Org, L=City, S=State, C=US"
echo Creating clients keystore...
keytool -genkey -alias [email protected] -keyalg RSA -keysize 2048 -keystore martim.jceks -storetype JCEKS -storepass %password% -keypass %password% -noprompt -dname "CN=myclient, OU=OrgUnit, O=Org, L=City, S=State, C=US"
keytool -genkey -alias [email protected] -keyalg RSA -keysize 2048 -keystore daniel.jceks -storetype JCEKS -storepass %password% -keypass %password% -noprompt -dname "CN=myclient, OU=OrgUnit, O=Org, L=City, S=State, C=US"
keytool -genkey -alias [email protected] -keyalg RSA -keysize 2048 -keystore joao.jceks -storetype JCEKS -storepass %password% -keypass %password% -noprompt -dname "CN=myclient, OU=OrgUnit, O=Org, L=City, S=State, C=US"
echo Exporting certificates...
keytool -export -alias myserver -file server.cer -keystore server.jceks -storepass %password%
keytool -export -alias [email protected] -file martim.cer -keystore martim.jceks -storepass %password%
keytool -export -alias [email protected] -file daniel.cer -keystore daniel.jceks -storepass %password%
keytool -export -alias [email protected] -file joao.cer -keystore joao.jceks -storepass %password%
echo Creating truststore and importing certificates...
keytool -import -alias myserver -file server.cer -keystore truststore.jceks -storetype JCEKS -storepass %password% -noprompt
keytool -import -alias [email protected] -file martim.cer -keystore truststore.jceks -storetype JCEKS -storepass %password% -noprompt
keytool -import -alias [email protected] -file daniel.cer -keystore truststore.jceks -storetype JCEKS -storepass %password% -noprompt
keytool -import -alias [email protected] -file joao.cer -keystore truststore.jceks -storetype JCEKS -storepass %password% -noprompt
echo Done.