SSL Certificate CSR Creation for Java Based Web Servers.
If you already have your SSL Certificate and just need to install it, see
SSL Certificate Installation :: Java Web Servers.
How to generate a CSR using Java Keytool
**NOTE: You must generate a new keystore through this process. If you try to install a new certificate to an old keystore your certificate will not work properly. Backup and remove any old keystores if necessary before beginning this process.
Before you can create your CSR, you need to create your Java keystore. Your Java keystore contains your private key. Run the following command to create your 2048 bit Java keystore: keytool -genkey -alias myalias -keyalg RSA –keysize 2048 -keystore c: yoursite.keystore 2. Note the alias you use here to create the keystore. I need to create public and private RSA keys for a client/server application, and I'm using the JSch library to do so. I've been generating 4096-bit keys up until now, as I'd like to have the best security possible. However, this takes 35 minutes, whereas generating a 2048-bit key takes something to the tune of 10 seconds. Have an sscce. Generate RSA key pair and encode private as string. Ask Question Asked 10 years ago. Sign up using Google. How do I generate RSA key pair in JAVA (in openssl format) 0. How to generate unique api key and secret key in java. Using PKCS 7 Cryptography.
Recommended: Save yourself some time by using our new Java Keytool CSR Wizard to create your CSR with Keytool. Just fill in the details, click Generate, and paste your customized keytool command into your terminal.
If you prefer to roll your own keytool commands to generate your CSR, just follow our old instructions below:
Create a New Keystore
You will be using the keytool command to create your new key-CSR pairing. Enter the following:
keytool -genkey -alias server -keyalg RSA -keysize 2048 -keystore yourdomain.jks
'Yourdomain' is the name of the domain you are securing. However, if you are ordering a Wildcard Certificate, do not include * in the beginning of the filename as this is not a valid filename character.
You will be prompted for the DN information. Please note: when it asks for first and last name, this is not YOUR first and last name, but rather your domain name and extension(i.e., www.yourdomain.com). If you are ordering a Wildcard Certificate this must begin with *. (example: *.digicert.com)
Confirm that the information is correct by entering 'y' or 'yes' when prompted. Next you will be asked for your password to confirm. Make sure to remember the password you choose.
Rsa Signing Example
Generate Your CSR with Your New keystore
Next, use keytool to actually create the Certificate Signing Request. Enter the following:
keytool -certreq -alias server -keyalg RSA -file yourdomain.csr -keystore yourdomain.jks
Again, 'yourdomain' is the name of the domain you are securing. (without the * character if you are ordering a Wildcard Certificate).
Enter the keystore password.
Then the SSL Certificate CSR file is created. Open the CSR with a text editor, and copy and paste the text (including the BEGIN and END tags) into the DigiCert web order form.
After you receive your SSL Certificate from DigiCert, you can install it.
See SSL Certificate Installation :: Java Web Servers.
Generating a CSR for Issuance of an SSL Certificate with Keytool
How to generate a Certificate Signing Request for your Java Web Server
A CSR is encoded text that contains information about the certificate requester. This information includes, but is not limited to, the publisher name for the certificate (referred to as a 'Common Name'), organization name (if applicable), and a contact email for the certificate. When creating a CSR it will export two files, these two files will be your CSR, which will be requested during enrollment, and a corresponding private key which should not be shared and will be required during installation.
Note: Before proceeding with the instructions below, confirm the Java Development Kit (JDK) is installed correctly on your server or local computer.
The following instructions will guide you through creating a Java Keystore File and CSR. If you already generated the CSR and received your trusted Code Signing Certificate, please click here for Code Signing downloading/exporting Instructions.
1. Run the Keystore prompt
To make a keystore and key file, run the command prompt below:
keytool -genkey -alias server -keyalg RSA -keysize 2048 -keystore keystore.jks
2. Enter the required information, when prompted
- Enter keystore password:
- Re-enter new password:
- What is your first and last name?
- What is the name of your organization unit?
- What is the name of your organization?
- What is the name of your City or Locality?
- What is the name of your State or Province?
- What is the two-letter country code for this unit?
- Is CN = CompanyName or Firstname Lastname, OU=DeparmentName, O=CompanyName, L=City, ST=State, C=CountryCode correct?
- Enter key password for :
The above command will create a Java keystore file called keystore.jks
3. Run the CSR prompt
To make the CSR from the keystore, run the command prompt below:keytool -certreq -alias server -file csr.csr -keystore keystore.jks
Enter keystore password:
Note: The keystore password is the same password you created in step 2.
The above command will create the CSR and private key and saves as a .csr file and a .jks file.
4. Generate the order
- Copy the newly generated CSR and include the header —–BEGIN NEW CERTIFICATE REQUEST—- and footer —–END NEW CERTIFICATE REQUEST—– tags.
- Login to your account
- Locate your Incomplete Order
- Click Generate Cert Now
- Select the option to Create a link
- Click the link
- Select Java as your Code Signing Certificate Type
- Continue and paste in your CSR
- Complete the remaining enrollment steps
- Congrats! You now have an Order Number
After you complete the validation process and receive the trusted Code Signing Certificate from the issuing Certificate Authority, please click here and proceed to the next step of using our Code Signing Installation Instructions.