This topic explains how to generate a Certificate Signing Request (CSR) file using OpenSSL or Keytool before applying for an SSL certificate.
Before you begin
To apply for an SSL certificate, you need a private key file and a CSR file. The CSR file contains your public key and organizational information, which the certificate authority (CA) uses for validation.
SSL Certificates Service supports two tools for generating a CSR file:
|
Tool |
Best for |
|
OpenSSL |
Linux/macOS servers and standard RSA key generation |
|
Keytool |
Java-based servers (Tomcat) and environments that require Chinese character input |
Requirements for the CSR file:
The key must be RSA type, 2,048 bits in length.
For a multi-domain or wildcard certificate, specify a single domain name in the
Common Namefield (orWhat is your first and last name?in Keytool).If you enter Chinese characters, encode them in UTF-8. Keytool handles this natively; OpenSSL requires UTF-8 support to be configured.
Use the system-generated CSR in SSL Certificates Service when possible to avoid validation failures caused by incorrectly formatted input. For more information about how to address a validation failure, see The "Primary domain name cannot be empty" error is returned when I upload my CSR file. What do I do?. If you generate a CSR manually, keep the private key confidential and back it up immediately.
Note: To enter Chinese information, use Keytool rather than OpenSSL.
Generate a CSR file
Use OpenSSL to generate a CSR file
Log in to your server and navigate to the directory where you want to store the key and CSR files.
Install OpenSSL if it is not already installed. For installation instructions, see the OpenSSL website.
-
Run the following command to generate a private key and CSR file simultaneously:
openssl req -new -nodes -sha256 -newkey rsa:2048 -keyout [$Key_File] -out [$OpenSSL_CSR]NoteNote: The command parameters are described as follows:
Parameter
Description
-newGenerates a new CSR file
-nodesCreates an unencrypted private key file
-sha256Uses SHA-256 as the digest algorithm
-newkey rsa:2048Generates a new 2,048-bit RSA private key
[$Key_File]The filename for the private key
[$OpenSSL_CSR]The path where the CSR file is saved
The following output is returned.

-
Enter the required information when prompted:
Field
Description
Organization Name
Your company name (Chinese or English)
Organizational Unit Name
Your department name (Chinese or English)
Country Code
The two-letter ISO country code of your organization. For example,
CNfor China.State or Province
The state or province name (Chinese or English)
Locality
The city name (Chinese or English)
Common Name
The domain name for which you are applying for the certificate
Email Address
Optional
A challenge password
Optional
Retrieve the generated private key file and CSR file from the current directory.
Use Keytool to generate a CSR file
Log in to your server and navigate to the directory where you want to store the keystore and CSR files.
-
Verify that Keytool is available. Keytool is included in the Java Development Kit (JDK).
NoteNote: In most cases, Keytool is installed with the JDK. Run
keytool -helpto confirm. -
Run the following command to generate a keystore file:
keytool -genkey -alias [$Alias] -keyalg RSA -keysize 2048 -keystore [$Keytool_Path]NoteNote: The command parameters are described as follows:
Parameter
Description
-keyalgThe key type. Must be
RSA.-keysizeThe key length. Must be
2048.[$Alias]A custom alias for the certificate. Use the same alias in all subsequent Keytool commands for this certificate.
[$Keytool_Path]The path where the keystore file is saved
Enter a password to protect the keystore when prompted. Store this password securely — you need it to access the private key and to generate the CSR in a later step.
-
Enter the required information when prompted:
Field
Description
First and last name
The domain name for which you are applying for the certificate
Name of your organizational unit
Your department name
Name of your organization
Your company name
Name of your city or locality
Your city name
Name of your state or province
Your state or province name
Two-letter country code for this unit
The two-letter ISO country code of your organization
Confirm the input by entering
Y.Enter the key password when prompted. Press Enter to use the same password as the keystore.
-
Run the following command to export a CSR file from the keystore:
keytool -certreq -sigalg SHA256withRSA -alias [$Alias] -keystore [$Keytool_Path] -file [$Keytool_CSR]NoteNote: The command parameters are described as follows:
Parameter
Description
-sigalg SHA256withRSAThe digest algorithm for the CSR signature
[$Alias]Must match the alias used when the keystore was created
[$Keytool_Path]The path to the keystore file
[$Keytool_CSR]The path where the CSR file is saved
Enter the keystore password when prompted to confirm and finalize CSR generation.
Application scope
SSL Certificates Service