Skip to content

Instantly share code, notes, and snippets.

@madumalt
Forked from mefarazath/KeyTool Commands
Created September 7, 2017 16:11
Show Gist options
  • Save madumalt/6ff61ba8f7d56f049ea931e883c7fe3b to your computer and use it in GitHub Desktop.
Save madumalt/6ff61ba8f7d56f049ea931e883c7fe3b to your computer and use it in GitHub Desktop.
# export a public certificate
keytool -export -alias wso2carbon -file key.crt -keystore wso2carbon.jks
or
keytool -export -keystore pathToKeystore -rfc -alias aliasNameForCertificate
#print out the certificate
openssl x509 -text -inform DER -in key.crt
or
keytool -printcert -rfc -file pathToCertificate
#Import a cert into a keystore
keytool -import -trustcacerts -alias mydomain -file mydomain.crt -keystore keystore.jks
Extract the Private Key
-----------
1. Import JKS --> PKCS12 store
keytool -importkeystore -srckeystore wso2carbon.jks -destkeystore wso2carbon.p12 -srcstoretype JKS -deststoretype PKCS12 -srcstorepass wso2carbon -deststorepass wso2carbon -srcalias wso2carbon -destalias wso2carbon -srckeypass wso2carbon -destkeypass wso2carbon
2. Extract Private Key
openssl pkcs12 -in wso2carbon.p12 -out wso2privateKey.pem -passin pass:wso2carbon -passout pass:wso2carbon
3. RSA key extraction
openssl rsa -in wso2privateKey.pem -out wso2RSA.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment