Skip to content

Instantly share code, notes, and snippets.

@xboard
Last active October 17, 2017 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xboard/a805fbdfd60a9d055fa2c5d711ebeec3 to your computer and use it in GitHub Desktop.
Save xboard/a805fbdfd60a9d055fa2c5d711ebeec3 to your computer and use it in GitHub Desktop.
# Run the following OpenSSL command to generate your private key and public certificate. Answer the questions and enter the Common Name when prompted.
openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem
# Review the created certificate:
openssl x509 -text -noout -in certificate.pem
# Combine your key and certificate in a PKCS#12 (P12) bundle:
openssl pkcs12 -inkey key.pem -in certificate.pem -export -out certificate.p12
# Validate your P12 file.
openssl pkcs12 -in certificate.p12 -noout -info
# Import the .p12 file to a keystore (.jks) by executing the following command:
keytool -importkeystore -deststorepass [password] -destkeystore [filename-new-keystore.jks] -srckeystore [filename-new-PKCS-12.p12] -srcstoretype PKCS12
# Rename the default alias (1) to a more convenient alias (server's hostname):
keytool.exe -changealias -keystore [keystore.jks] -alias 1 -destalias [hostname]
# Add to JDK cacerts
keytool -import -keystore <%JAVA_HOME%>/jre/lib/security/cacerts -storepass changeit -noprompt -alias [servername] -file certificate.cer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment