Skip to content

Instantly share code, notes, and snippets.

@robvanoostenrijk
Created July 18, 2017 03:31
Show Gist options
  • Save robvanoostenrijk/6f88d8248f4e2f86eef920ec39992b17 to your computer and use it in GitHub Desktop.
Save robvanoostenrijk/6f88d8248f4e2f86eef920ec39992b17 to your computer and use it in GitHub Desktop.
Java - Generate Self-Signed SSL Certificate
# Generate a self-signed certificate in a Java keystore as a single line command
# Note this generates a SAN certificate for machine.domain, localhost & 127.0.0.1
keytool -genkeypair \
-keyalg RSA \
-keysize 2048 \
-alias "machine.domain" \
-keystore /discovery-service/config/keystore.jks \
-keypass "key-password" \
-storepass "store-password" \
-validity 1095 \
-ext san=dns:localhost \
-ext san=ip:127.0.0.1 \
-dname "CN=machine.domain, OU=OrgUnit, O=Org, L=City, ST=State, C=US"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment