Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate x.509 certificate by the Java keytool command-line interface

I am using RESTEasy encryption. For that I have to generate x.509 certificate by the Java 'keytool' command-line interface.

Please help me

Thank you

like image 578
Amit Sharma Avatar asked May 31 '13 07:05

Amit Sharma


People also ask

How do I generate an x 509 certificate?

Open cmd prompt, change directory to desktop & type command- openssl. It is a process of creating a simple x509 certificate that will be used for digital signatures. Press enter and fill in all the required information like the password for creating keys & a few personal information.

What is X 509 Certificate in Java?

The Java Certificate class has one subclass - the X509Certificate class. This class represents an X. 509 certificate which is used as identity certificate in HTTPS and TLS.


1 Answers

This is the command to generate self signed certificates. All in one line

keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks 
        -storepass password -validity 360 -keysize 2048

When you run this command, it will ask you for the details of the signatory. These will be the details of your organization. Provide all the details and it will create a new self signed certificate in keystore keystore for you.

NOTE: When it ask for your first and last name, give the domain name of the server which will be the entry point for your users. i.e. www.myserver.com

If you already have a keystore then you can use your existing keystore to add new certificate otherwise this command will create the keystore keystore.jks with the password and add the certificate to the new keystore. Note that if you already have a keystore then you need to provide the password of the existing keystore in -storepass parameter of this command.

For more details, see the keytool man page: http://docs.oracle.com/javase/1.5.0/docs/tooldocs/solaris/keytool.html

Here you will find details of all the available options you can use with the keytool command.

like image 103
Raza Avatar answered Sep 23 '22 03:09

Raza