Java Key Store: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:
keytool -genkey -keyalg RSA -keysize 2048 -validity 7300\
keytool -genkey -keyalg RSA -keysize 2048 -validity 7300\
  -dname "CN=Chorke Academia, OU=Academia, O=Chorke Inc, L=Kuala Lumpur, ST=WP, C=MY"\
  -dname "CN=Chorke Academia, OU=Academia, O=Chorke Inc, L=Kuala Lumpur, ST=WP, C=MY"\
  -keystore clients.jks -alias xpresscover\
  -keystore clients.jks -alias academia\
  -storepass storepasswd\
  -storepass storepasswd\
  -keypass storepasswd
  -keypass storepasswd
</source>
</source>


== Manipulation ==
==Create==
<source lang="bash">
<source lang="bash">
# show trusted root ca entries with empty/blank password
keytool -genkey -keyalg RSA -keysize 2048 -validity 7300\
keytool -keystore "$JAVA_HOME/jre/lib/security/cacerts" -list
-dname "CN=Chorke Academia, OU=Academia, O=Chorke Inc, L=Kuala Lumpur, ST=WP, C=MY"\
-keystore clients.jks -alias academia\
-storepass storepasswd
</source>


# show trusted certificate entries with store password
==Import==
keytool -keystore "$HOME/.chorke/jks/chorke.jks" -list
<source lang="bash">
keytool -importkeystore -deststoretype pkcs12\
-srckeystore  clients.jks\
-destkeystore  servers.jks\
-srcstorepass  storepasswd\
-deststorepass storepasswd\
-srcalias      academia\
-destalias    academia
</source>


# change proprietary jks format to pkcs12
===Root CA Cert===
keytool -importkeystore -srckeystore chorke_source.jks \
<source lang="bash">
-destkeystore chorke_target.jks -deststoretype pkcs12
keytool -importcert -trustcacerts\
-storepass storepasswd\
-keystore  clients.jks\
-file  rootca.cer
-alias rootca\
</source>
</source>


===Sub CA Cert===
<source lang="bash">
<source lang="bash">
# import certificate with alias in java security
keytool -importcert -trustcacerts\
keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
-storepass storepasswd\
-alias ckirootca -file ckirootca.cer
-keystore clients.jks\
-file subca.cer\
-alias subca
</source>


keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
===Certificate===
-alias ckisubca -file ckisubca.cer
<source lang="bash">
 
keytool     -importcert\
keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
-storepass storepasswd\
-alias chorke -file chorke.crt
-keystore clients.jks\
-file software.crt\
-alias software
</source>
</source>


==Certificate List==
<source lang="bash">
<source lang="bash">
keytool -storepass storepasswd -importcert -keystore jks/chorke.jks \
keytool -list -keystore clients.jks -storepass storepasswd
-trustcacerts -alias ckirootca-file jks/ckirootca.cer
 
keytool -storepass storepasswd -importcert -keystore jks/chorke.jks \
-trustcacerts -alias ckisubca-file jks/ckisubca.cer
 
keytool -storepass storepasswd -importcert -keystore jks/chorke.jks \
-alias chorke -file jks/chorke.crt
</source>
</source>


==Knowledge==
<source lang="bash">
<source lang="bash">
# debugging certificate handshacking
# debugging certificate handshacking

Revision as of 03:02, 3 March 2021

keytool -genkey -keyalg RSA -keysize 2048 -validity 7300\
 -dname "CN=Chorke Academia, OU=Academia, O=Chorke Inc, L=Kuala Lumpur, ST=WP, C=MY"\
 -keystore clients.jks -alias academia\
 -storepass storepasswd\
 -keypass storepasswd

Create

keytool -genkey -keyalg RSA -keysize 2048 -validity 7300\
 -dname "CN=Chorke Academia, OU=Academia, O=Chorke Inc, L=Kuala Lumpur, ST=WP, C=MY"\
 -keystore clients.jks -alias academia\
 -storepass storepasswd

Import

keytool -importkeystore -deststoretype pkcs12\
 -srckeystore   clients.jks\
 -destkeystore  servers.jks\
 -srcstorepass  storepasswd\
 -deststorepass storepasswd\
 -srcalias      academia\
 -destalias     academia

Root CA Cert

keytool -importcert -trustcacerts\
 -storepass storepasswd\
 -keystore  clients.jks\
 -file  rootca.cer
 -alias rootca\

Sub CA Cert

keytool -importcert -trustcacerts\
 -storepass storepasswd\
 -keystore  clients.jks\
 -file  subca.cer\
 -alias subca

Certificate

keytool     -importcert\
 -storepass storepasswd\
 -keystore  clients.jks\
 -file  software.crt\
 -alias software

Certificate List

keytool -list -keystore clients.jks -storepass storepasswd

Knowledge

# debugging certificate handshacking
service='api.chorke.org:5443/soap/services';\
echo -e "GET / HTTP/1.0\r\n" | openssl s_client \
-connect $service -CAfile chorke_client.pem

References