Generating a CSR on Windows Using OpenSSL

Author:Vishal Singh
Updated:Mar 19, 2025

To generate a Certificate Signing Request (CSR) for your SSL certificate using OpenSSL, follow these organized steps:

  1. OpenSSL Command Execution:

    • Open a terminal or command prompt and run the following command to create the private key and CSR:
      openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server_csr.txt -subj "/C=US/ST=California/L=New York/O=Company Name/OU=IT/CN=www.example.com"
      
    • Replace the placeholders with your actual information:
      • C=US for your country (e.g., United States).
      • ST=California for your state.
      • L=New York for your city.
      • O=Company Name for your organization.
      • OU=IT for your department or leave as NA if not applicable.
      • CN=www.example.com for your domain name. Use *.example.com for a wildcard SSL.
  2. Verify and Copy CSR Content:

    • Open server_csr.txt using a text editor (e.g., Notepad on Windows) by running:
      notepad server_csr.txt
      
    • Copy the entire content from the start to the end of the file.
  3. Apply for SSL Certificate:

    • Submit the CSR to your Certificate Authority (CA). Ensure the CA receives the correct content without any errors.
  4. Convert to PFX if Needed:

    • Once you receive the SSL certificate, typically in .cer or .p7b format, convert it to a .pfx file using OpenSSL if installing on Windows:
      openssl pkcs12 -export -out your_certificate.pfx -in certificate.cer -key server.key -certfile root.cer
      
    • Replace certificate.cer with the actual file received from the CA.
  5. Installation and Testing:

    • Install the .pfx file on your server.
    • Test SSL functionality by accessing your website to ensure the certificate is correctly implemented.
  6. Security Considerations:

    • Ensure OpenSSL and related files have appropriate permissions for the user running the service.
    • Backup both the private key (server.key) and the SSL certificate securely.