CSR Generator (Certificate Signing)

Generate a PKCS#10 Certificate Signing Request (CSR) and private key in-browser with OpenSSL terminal command.

4.9 / 5· 148 verified ratings
•
100% Client-Side Privacy
•
Verified 2026 Engine
Loading tool engine...
Frequently Used With:Base64 Encoder & Decoder →MD5 Hash Generator →JWT Decoder →HMAC Signature Generator →
Institutional-Grade Accuracy & Client-Side Privacy Guarantee

Unlike conventional calculator sites that send your financial numbers, payload data, or code snippets across remote web servers, Affi-Chain processes all mathematical derivations, algorithms, and data parsing 100% locally within your browser sandbox. No tracking cookies, no server-side retention, and zero transmission lag.

What is a Certificate Signing Request (CSR)?

A Certificate Signing Request (CSR) is an encoded, standardized public-key message defined under PKCS #10 (Public-Key Cryptography Standards) and standardized by the Internet Engineering Task Force (IETF) in RFC 2986.

When a system administrator or software engineer deploys a secure Transport Layer Security (TLS/SSL) certificate on a web server, mail gateway, or Kubernetes ingress, the server does not simply request a certificate with a domain name. Instead, the server generates a private/public cryptographic keypair locally, bundles the public key together with verified organization identity metadata and Subject Alternative Names (SANs), signs the bundle with its own private key (establishing cryptographic Proof of Possession), and formats the output as a Base64-encoded PEM file:

-----BEGIN CERTIFICATE REQUEST-----
MIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxDzANBgNVBAgMBk9yZWdvbjEPMA0G
... (Base64 ASN.1 DER Encoded Structure) ...
-----END CERTIFICATE REQUEST-----

The applicant submits this CSR to a trusted Certificate Authority (CA)—such as Let's Encrypt, DigiCert, Sectigo, or a corporate internal HashiCorp Vault CA. The CA validates domain ownership (via ACME HTTP-01 or DNS-01 challenges), verifies organizational legitimacy, and issues a cryptographically signed X.509 server certificate.


Public Key Infrastructure (PKI) Workflow Architecture

The generation and issuance of an X.509 TLS certificate follows a strict, non-reversible cryptographic lifecycle:

flowchart TD
    subgraph ClientHost [Local Server / Ingress Controller]
        KeyGen["Generate Cryptographic Keypair (ECDSA P-256 or RSA 2048/4096)"]
        KeyGen --> PrivKey["Private Key (server.key): NEVER SHARED / STORED SECURELY"]
        KeyGen --> PubKey["Public Key Component"]
        
        Metadata["Collect X.500 Subject Attributes & Subject Alternative Names (SAN)"]
        PubKey & Metadata --> CSRBuild["Construct PKCS#10 CSR Object"]
        PrivKey --> CSRSign["Sign CSR with Local Private Key (Proof of Possession)"]
        CSRBuild --> CSRSign
        CSRSign --> CSROutput["Export CSR PEM File (server.csr)"]
    end
    
    subgraph CertAuthority [Certificate Authority: DigiCert / Let's Encrypt]
        CSROutput --> SubmitCA["Submit CSR to Certificate Authority"]
        SubmitCA --> VerifyDomain["Execute Domain Control Validation (ACME DNS-01 / HTTP-01)"]
        VerifyDomain --> CASign["CA Signs Public Key with CA Root/Intermediate Key"]
        CASign --> IssuedCert["Issue X.509 Public Certificate (server.crt)"]
    end
    
    IssuedCert --> Deploy["Deploy server.crt + server.key onto Web Server (Nginx, Caddy, Envoy)"]

Anatomy of a CSR: X.500 Distinguished Name (DN) & SAN Matrix

A PKCS#10 CSR contains three core components encoded in Abstract Syntax Notation One (ASN.1) using Distinguished Encoding Rules (DER):

Attribute FieldDistinguished Name (DN) KeySpecification RequirementPurpose & Production Best Practice
Common NameCNDeprecated as sole identifierPrimary Fully Qualified Domain Name (FQDN), e.g. affichain.com. Modern browsers ignore CN if SAN is present.
Subject Alternative NamesSANMandatory (RFC 5280 / RFC 2818)The modern standard for domain matching. Defines all valid hosts: DNS:affichain.com, DNS:*.affichain.com, IP:198.51.100.1.
Organization NameORequired for OV & EV CertsLegal corporate business entity name, e.g. AffiChain Technologies, Inc..
Organizational UnitOUOptional (Deprecated by CAs)Internal department name (e.g. Infrastructure Engineering). Largely phased out by public CAs.
Locality / CityLRequired for OV & EV CertsCity or municipality of corporate headquarters (e.g. San Francisco).
State / ProvinceSTRequired for OV & EV CertsFull un-abbreviated state or province name (e.g. California).
Country CodeCMandatoryExact two-letter ISO 3166-1 alpha-2 country code (e.g. US, GB, DE, IN).
Public Key AlgorithmN/AMandatorySpecifies whether the key is ECDSA (prime256v1) or RSA (2048/4096-bit).
Signature AlgorithmN/AMandatoryCryptographic hash used to sign request, typically SHA256withECDSA or SHA256withRSAEncryption.

Cryptographic Key Selection: RSA vs. ECDSA for CSRs

DimensionRSA 2048-BitRSA 4096-BitECDSA (NIST P-256 / secp256r1)ECDSA (NIST P-384)
NIST Security Strength112 bits128 bits128 bits192 bits (Top Secret)
Private Key Size2,048 bits4,096 bits256 bits384 bits
CSR File Size$\approx 1.1\text{ KB}$$\approx 1.8\text{ KB}$$\approx 650\text{ bytes}$$\approx 850\text{ bytes}$
TLS Handshake SpeedBaselineSlow (-65% throughput)4x to 6x Faster than RSA3x Faster than RSA
Legacy Compatibility99.9% (Ancient legacy clients)99.8%99.5% (All modern browsers/OS)Modern enterprise clients
Recommended ChoiceLegacy fallback systemsHigh-security legacyModern Cloud StandardGovernment CNSA Profile

Modern high-performance infrastructure standardizes on ECDSA P-256: it provides identical 128-bit cryptographic strength to RSA 3072, but slashes TLS handshake CPU overhead and packet sizes dramatically.


Practical Implementation Examples

Python: Automated ECDSA Key & CSR Generator (cryptography)

The following production script generates a private ECDSA P-256 key, constructs a PKCS#10 CSR with comprehensive Subject Alternative Names (SAN), and exports both objects in PEM format:

from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography import x509
from cryptography.x509.oid import NameOID
import ipaddress

def generate_csr_and_key(
    common_name: str,
    organization: str,
    country_code: str,
    state: str,
    city: str,
    alternative_domains: list = None
) -> dict:
    # 1. Generate Private Key (ECDSA NIST P-256)
    private_key = ec.generate_private_key(ec.SECP256R1())

    # 2. Build Subject Distinguished Name (DN)
    subject = x509.Name([
        x509.NameAttribute(NameOID.COUNTRY_NAME, country_code),
        x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, state),
        x509.NameAttribute(NameOID.LOCALITY_NAME, city),
        x509.NameAttribute(NameOID.ORGANIZATION_NAME, organization),
        x509.NameAttribute(NameOID.COMMON_NAME, common_name),
    ])

    # 3. Assemble Subject Alternative Names (SAN)
    san_list = [x509.DNSName(common_name)]
    if alternative_domains:
        for domain in alternative_domains:
            san_list.append(x509.DNSName(domain))

    # 4. Construct PKCS#10 CSR Builder
    builder = x509.CertificateSigningRequestBuilder()
    builder = builder.subject_name(subject)
    builder = builder.add_extension(
        x509.SubjectAlternativeName(san_list),
        critical=False
    )

    # 5. Sign CSR with the Private Key (Proof of Possession)
    csr = builder.sign(private_key, hashes.SHA256())

    # 6. Serialize to PEM format
    private_key_pem = private_key.private_bytes(
        encoding=serialization.Encoding.PEM,
        format=serialization.PrivateFormat.PKCS8,
        encryption_algorithm=serialization.NoEncryption()
    ).decode('utf-8')

    csr_pem = csr.public_bytes(serialization.Encoding.PEM).decode('utf-8')

    return {
        "common_name": common_name,
        "private_key_pem": private_key_pem,
        "csr_pem": csr_pem
    }

# Example Generation
result = generate_csr_and_key(
    common_name="affichain.com",
    organization="AffiChain Corp",
    country_code="US",
    state="California",
    city="San Francisco",
    alternative_domains=["www.affichain.com", "api.affichain.com"]
)

print("Generated Certificate Signing Request (server.csr):\n")
print(result["csr_pem"])

OpenSSL CLI Command-Line Generation

To generate an RSA-2048 key and CSR with SAN extensions directly from the terminal without interactive prompts:

# 1. Generate ECDSA P-256 Key & CSR in a single command
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 \
  -nodes -keyout server.key -out server.csr \
  -subj "/C=US/ST=California/L=San Francisco/O=AffiChain/CN=affichain.com" \
  -addext "subjectAltName=DNS:affichain.com,DNS:www.affichain.com"

# 2. Inspect and verify CSR contents
openssl req -text -noout -verify -in server.csr

Critical Edge Cases & Common Security Traps

1. The Fatal "Private Key Upload" Security Vulnerability

A dangerous pitfall is using unverified online web forms that generate CSRs and private keys on remote third-party servers. Your private key must never leave the machine that will host the TLS certificate. If an external server generates or stores your private key, that third party can eavesdrop on encrypted traffic or execute man-in-the-middle (MITM) attacks. Client-side tools (such as Affi-Chain's CSR Generator) use the W3C Web Crypto API to ensure keys are generated strictly in local browser memory without network transmission.

2. Wildcard Domain Scope Limitations

A common misconception is that a wildcard certificate for *.example.com covers all subdomains indefinitely. Under RFC 6125 §6.4.3:

  • *.example.com secures api.example.com, shop.example.com, and mail.example.com.
  • It DOES NOT secure multi-level subdomains like test.api.example.com or dev.shop.example.com.
  • It DOES NOT secure the naked root apex domain example.com. To secure both the apex domain and its first-level subdomains, the CSR must explicitly include both example.com and *.example.com in the Subject Alternative Names (SAN) extension.

3. Missing SAN Extensions Causing Browser Rejections

Historically, older SSL implementations used only the Common Name (CN) field. Since 2017, Google Chrome, Mozilla Firefox, and Apple Safari strictly reject certificates that lack the SubjectAlternativeName extension, throwing fatal NET::ERR_CERT_COMMON_NAME_INVALID errors even if the Common Name is accurate. Every modern CSR must explicitly include SAN records.

Frequently Asked Questions

What is a Certificate Signing Request (CSR)?
A CSR is an encoded text block containing your domain name, organization details, and public key that you submit to a Certificate Authority (CA) to purchase or issue an SSL/TLS certificate.
Is it safe to generate a private key in the browser?
Yes. This generator uses the native W3C Web Cryptography API (window.crypto.subtle) running in isolated local memory. Your private key is created on your device and is never transmitted across the network.
What bit length is recommended for RSA keys?
2048-bit RSA is the current industry standard across public CAs. 4096-bit provides higher security for root and intermediate certificates, while ECDSA (P-256) offers modern, fast elliptic curve security.

Explore Related Utilities