Skip to content

Instantly share code, notes, and snippets.

@sunb0002
Last active October 29, 2018 04:17
Show Gist options
  • Save sunb0002/93cec26875ed1a7bb749671bb257ffbb to your computer and use it in GitHub Desktop.
Save sunb0002/93cec26875ed1a7bb749671bb257ffbb to your computer and use it in GitHub Desktop.
## Generate a keypair
openssl req -x509 -newkey rsa:2048 -sha256 -keyout example.key -out example.crt -subj "/CN=example.com" -days 3650
## Create PFX keystore with this keypair
openssl pkcs12 -inkey example.key -in example.crt -export -out keystore.pkcs12
## Convert PFX keystore into Java JKS keystore
keytool -importkeystore -srckeystore keys.pkcs12 -srcstoretype pkcs12 -destkeystore keystore.jks
## Other often used
keytool -list -v -keystore keystore.jks -alias mydomain
keytool -delete -alias mydomain -keystore keystore.jks
keytool -import -alias csl -keystore keystore.jks -file csl.crt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment