Skip to content

How to Generate a CSR with OpenSSL

DodaTech Updated 2026-06-24 2 min read

A Certificate Signing Request (CSR) is a formal request to a Certificate Authority for an SSL certificate. It contains your public key and identifying information. This guide walks through the specific troubleshooting steps to diagnose and resolve CSR generation issues.

Before You Begin

Before you begin, be sure to have the following in place:

  • A Linux server with the relevant software installed
  • Access to the command line interface
  • Appropriate permissions (root or sudo)

Quick Fix

Wrong

openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr

Wrong: CSR without SAN extension

openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr -subj "/CN=example.com/O=Example Inc/C=US" -addext "subjectAltName=DNS:example.com,DNS:www.example.com"

Right: CSR with SAN for multiple domains

Output

-----BEGIN CERTIFICATE REQUEST-----\nCertificate Request:\n    Subject: CN=example.com, O=Example Inc, C=US\n    Requested Extensions:\n        X509v3 Subject Alternative Name:\n            DNS:example.com, DNS:www.example.com

Prevention

To avoid future issues, follow these best practices:

  • Always include SAN extension in CSRs -- modern browsers require it
  • Use the -addext flag with openssl 1.1.1+ to add SANs directly
  • Keep your private key secure -- it is the only secret in the key pair
  • Verify CSR content with openssl req -in server.csr -noout -text
  • Use a config file for complex CSR requirements instead of command-line flags

DodaTech Tools

For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.

Common Mistakes with csr generate

  1. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  2. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  3. Misunderstanding that String is [Char] with poor performance for large text operations

These mistakes appear frequently in real-world OPENSSL code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

What information is required in a CSR?|||A CSR must include the Common Name (CN), organization details (optional for DV certs), and the Subject Alternative Names (SANs) listing every domain the certificate should cover.
Can I reuse the same key pair for a new CSR? Yes. Run openssl req -new -key existing.key -out new.csr to generate a new CSR from an existing key. This is useful when renewing certificates.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro