Generating a CSR on Node.js - SSL Certificates - esadax.com

Author:Esadax
Updated:Apr 26, 2025

A Certificate Signing Request (CSR) is essential for obtaining an SSL/TLS certificate, which is used to secure your website with HTTPS. Below, we'll guide you through the process of generating a CSR using Node.js.

Step 1: Install OpenSSL

To create a CSR in Node.js, you'll need OpenSSL installed on your system. OpenSSL is commonly available on most Linux and macOS systems, but if you're using Windows, you can install it via Chocolatey or other package managers.

Step 2: Generate the CSR

Once OpenSSL is installed, you can generate a CSR by running the following command:

openssl req -x509 -newkey rsa:2048 -keyout privateKey.pem -out csr.pem -days 365 -nodes
  • req: This option specifies that we're creating a certificate request.
  • -x509: This indicates that the certificate is an X.509 certificate, which is the standard format for SSL certificates.
  • -newkey rsa:2048: This creates a new RSA private key with a 2048-bit length.
  • -keyout privateKey.pem: The path to save your private key file.
  • -out csr.pem: The path to save your CSR file.
  • -days 365: The number of days the certificate is valid (365 for one year).
  • -nodes: This ensures that the private key is not encrypted with a passphrase.

After running this command, you'll have two files:

  • privateKey.pem: Your private key used to sign the CSR.
  • csr.pem: Your Certificate Signing Request.

Step 3: Fill in the CSR Details

When prompted, fill in the necessary information for your CSR:

  1. Common Name (CN): This is the domain name or hostname of your website.
  2. Organization Name (O): The legal name of your organization.
  3. Organizational Unit (OU): Department or division within your organization.
  4. City, State, and Country: Your location information.
  5. Email Address: Your contact email.

Step 4: Submit the CSR to Esadax

Once you have the csr.pem file, upload it to Esadax's SSL/TLS certificate management interface. Follow these steps:

  1. Log in to your Esadax account.
  2. Navigate to the SSL/TLS section.
  3. Choose the domain for which you're applying the certificate.
  4. Upload your CSR file (csr.pem).
  5. Provide any additional required information, such as a C&A (Certification Authority Authorization) form if needed.

Step 5: Activate Your Certificate

After Esadax issues your SSL/TLS certificate, download it and install it on your server or website. Use the private key (privateKey.pem) to sign the certificate request when obtaining your SSL/TLS certificate from a Certificate Authority (CA).

Notes:

  • Ensure that you keep both csr.pem and privateKey.pem secure. Losing these files will prevent you from renewing your SSL/TLS certificate in the future.
  • If you need help with OpenSSL or the CSR process, Esadax's support team is available to assist.

Common Questions

  1. What if I lose my private key?

    • If you lose privateKey.pem, you won't be able to renew your SSL/TLS certificate. Ensure it's backed up securely.
  2. Why does the CSR require so much information?

    • CAs need detailed information to validate the request and ensure the certificate is issued to the correct entity.
  3. Can I use a different format for the CSR?

    • Most CAs accept CSRs in the X.509 format, but it's best to check with your preferred CA.

Need further assistance? Contact Esadax's support team via Live Chat or email for help with generating or managing your SSL/TLS certificates.