Get your FREE copy of "The Ultimate Guide of SSL"

Download Ebook

How to Create a Self Signed Certificate using Java Keytool

SSL Certificate is also important to secure java application using a self-signing certificate. In most cases you must use a CA verified certificate but you can also use a self-signed cert to secure your java app.

Steps to create a Self Signed Certificate using Java Keytool

  • Step 1. Open the command console
  • Step 2. Run this command (Where indicate the number of days for which the certificate will be valid)
keytool -genkey -keyalg RSA -alias selfsigned -ystore keystore.jks -storepass password -validity 365 -keysize 2048
  • Step 3. Enter a password for the keystore. Note this password as you require this for configuring the server
  • Step 4. When prompted for first name and last name, enter the domain name of the server.
  • For example, myserver or
  • Step 5. Enter the other details, such as Organizational Unit, Organization, City, State, and Country.
  • Step 6. When prompted with Enter key password for, press Enter to use the same password as the keystore password
  • Step 7. Run this command to verify the contents of the keystone
  • keytool -list -v -keystore selfsigned.jks
  • Step 8. When prompted, enter the keystore password note in Step 3.

    The basic information about the generated certificate is displayed. Verify that the Owner and Issuer are the same. Also, you should see the information you provided in Steps 4 and 5.

    Related Articles:

    Disclosure: AboutSSL appreciates your continuous support. It helps us tremendously to keep moving in the competitive SSL industry. Here most of the links which direct you to buy any SSL/TLS related service or products earns us a certain percentage of referral commission. Learn More