keytool command to create jks file code example

Example 1: how to add new certificate to jks file

keytool -importcert -file certificate.cer -keystore keystore.jks -alias "Alias"

Example 2: generate jks certificate

Rem Java Installation required
keytool -genkey -keyalg RSA -alias "localhost" -keystore "jenkins.jks" -validity 365 -keysize 2048 -dname "CN=localhost, OU=OU_name, O=OU_name, L=city, ST=State_name, C=two_letter_country_code" -ext SAN=dns:localhost,ip:192.168.56.1 -storepass changeit