Created
August 19, 2017 01:45
-
-
Save leonj1/13b258727b3d34d19ebe2602c7591960 to your computer and use it in GitHub Desktop.
How I create a Certificate for REST endpoints and import into Java Keystore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create cert and store | |
openssl genrsa -out server.key 2048 | |
openssl rsa -in server.key -out server.key | |
openssl req -sha256 -new -key server.key -out server.csr -subj '/CN=localhost' | |
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out localhost.crt | |
# convert to pkcs12, and then convert to Java keystore | |
openssl pkcs12 -export -in localhost.crt -inkey server.key -out server.p12 -name localhost -CAfile ca.crt -caname root | |
keytool -importkeystore -deststorepass changeit -destkeypass changeit -destkeystore keystore.jks -srckeystore server.p12 -srcstoretype PKCS12 -srcstorepass changeit -alias localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment