Skip to content

Instantly share code, notes, and snippets.

@satdrasing
Created November 24, 2019 07:40
Show Gist options
  • Select an option

  • Save satdrasing/4372e60b5118267c2dfd5ed8856834a4 to your computer and use it in GitHub Desktop.

Select an option

Save satdrasing/4372e60b5118267c2dfd5ed8856834a4 to your computer and use it in GitHub Desktop.

Revisions

  1. satdrasing created this gist Nov 24, 2019.
    21 changes: 21 additions & 0 deletions keystore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@

    ######## Generate a self-signed SSL certificate
    keytool -genkeypair -alias tomcat -keyalg RSA -keysize 2048 -keystore keystore.jks -validity 3650
    keytool -genkeypair -alias tomcat -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore keystore.p12 -validity 3650 #PKCS12

    keytool -list -v -keystore keystore.jks
    keytool -list -v -storetype pkcs12 -keystore keystore.p12 #PKCS12


    ######### Use an existing SSL certificate
    keytool -import -alias tomcat -file myCertificate.crt -keystore keystore.p12 -storepass password

    ######### Distribute the SSL certificate to clients
    keytool -export -keystore keystore.jks -alias tomcat -file myCertificate.crt

    ######### Import the certificate inside the JRE keystore
    keytool -importcert -file myCertificate.crt -alias tomcat -keystore $JDK_HOME/jre/lib/security/cacerts


    ##### view public key in using openssl
    keytool -list -rfc --keystore keystore.jks | openssl x509 -inform pem -pubkey