Java Key Store: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
<source lang="bash">
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 xpresscover\
-storepass storepasswd\
-keypass storepasswd
</source>
== Manipulation ==
== Manipulation ==
<syntaxhighlight lang="bash">
<source lang="bash">
# show trusted root ca entries with empty/blank password
# show trusted root ca entries with empty/blank password
keytool -keystore "$JAVA_HOME/jre/lib/security/cacerts" -list
keytool -keystore "$JAVA_HOME/jre/lib/security/cacerts" -list
Line 10: Line 18:
keytool -importkeystore -srckeystore chorke_source.jks \
keytool -importkeystore -srckeystore chorke_source.jks \
-destkeystore chorke_target.jks -deststoretype pkcs12
-destkeystore chorke_target.jks -deststoretype pkcs12
</syntaxhighlight>
</source>


<syntaxhighlight lang="bash">
<source lang="bash">
# import certificate with alias in java security
# import certificate with alias in java security
keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
Line 22: Line 30:
keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
-alias chorke -file chorke.crt
-alias chorke -file chorke.crt
</syntaxhighlight>
</source>


<syntaxhighlight lang="bash">
<source lang="bash">
keytool -storepass storepasswd -importcert -keystore jks/chorke.jks \
keytool -storepass storepasswd -importcert -keystore jks/chorke.jks \
-trustcacerts -alias ckirootca-file jks/ckirootca.cer
-trustcacerts -alias ckirootca-file jks/ckirootca.cer
Line 33: Line 41:
keytool -storepass storepasswd -importcert -keystore jks/chorke.jks \
keytool -storepass storepasswd -importcert -keystore jks/chorke.jks \
-alias chorke -file jks/chorke.crt
-alias chorke -file jks/chorke.crt
</syntaxhighlight>
</source>


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


== References ==
== References ==

Revision as of 02:50, 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 xpresscover\
 -storepass storepasswd\
 -keypass storepasswd

Manipulation

# show trusted root ca entries with empty/blank password
keytool -keystore "$JAVA_HOME/jre/lib/security/cacerts" -list

# show trusted certificate entries with store password
keytool -keystore "$HOME/.chorke/jks/chorke.jks" -list

# change proprietary jks format to pkcs12
keytool -importkeystore -srckeystore chorke_source.jks \
-destkeystore chorke_target.jks -deststoretype pkcs12
# import certificate with alias in java security
keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
-alias ckirootca -file ckirootca.cer

keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
-alias ckisubca -file ckisubca.cer

keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts \
-alias chorke -file chorke.crt
keytool -storepass storepasswd -importcert -keystore jks/chorke.jks \
-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
# 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