What a certificate signing request is
A certificate signing request (CSR) is what you send to a certificate authority (CA) to get a certificate. It holds your public key, the names you want the certificate to cover, and a signature made with the matching private key. The signature proves you hold that private key.
The format is PKCS#10, defined in RFC 2986. Like certificates, CSRs are DER-encoded and usually shared as PEM between BEGIN CERTIFICATE REQUEST and END CERTIFICATE REQUEST lines. Some older tools write NEW CERTIFICATE REQUEST; this decoder reads both.
A CSR contains no secret. It is safe to send to a CA, paste into a ticket or decode here. The private key stays with you.
What is inside a CSR
| Part | What it holds | Why it matters |
|---|---|---|
| Version | Always 0, shown as version 1 | Nothing to check |
| Subject | A distinguished name, such as C=US, O=Example Corp, CN=auth.example.com | Many public CAs ignore most of it for domain-validated certificates |
| Public key | The key type and size or curve | Decides the certificate’s key; it cannot change later |
| Attributes | Extra data, mainly the extension request | Holds the names and usages you ask for |
| Signature | Made with the private key, usually with SHA-256 | Proves possession of the key |
The extension request attribute carries the extensions you want in the certificate, most importantly subject alternative names (SAN). It can also ask for key usage and extended key usage. The CA decides what it actually issues; a request is only a request.
Why subject alternative names are the key check
Browsers and modern TLS clients match the host name only against the SAN extension. The common name in the subject is ignored. A certificate for auth.example.com with that name only in the CN will fail in browsers.
Public CAs that follow the CA/Browser Forum’s rules always put names in the SAN extension, and many copy the CN there for you. Private CAs, internal tools and older scripts often do not. Checking the CSR for a SAN before you submit it saves a round trip.
openssl req -new -newkey rsa:2048 -nodes \
-keyout auth.example.com.key -out auth.example.com.csr \
-subj "/CN=auth.example.com" \
-addext "subjectAltName=DNS:auth.example.com,DNS:login.example.com"What this decoder does and does not do
- It reads a PEM CSR, or its bare Base64, and decodes the subject, public key, signature algorithm, requested extensions and other attributes.
- It warns when no SAN is requested, when an RSA key is shorter than 2048 bits, and when the signature uses SHA-1 or MD5.
- It extracts the public key as PEM, which you can compare with the key you expect.
- It does not verify the CSR’s signature. The CA does that when you submit it.
- It does not create CSRs or keys. Use OpenSSL or your server’s tooling for that, so the private key never leaves the server.
How to check a CSR before ordering
- Paste the PEM request. A sample request for
auth.example.comis filled in to start with. - Check the subject. For a public certificate, the CN should be one of your host names; organization fields matter only for organization-validated certificates.
- Check the public key: RSA 2048 or larger, or EC P-256 or P-384.
- Check the requested subject alternative names list every host name the certificate must cover.
- If anything is wrong, generate a new CSR. A CSR cannot be edited, because the signature covers all of it.
Planning names for an identity server
An identity server often has more names than people expect. Before generating a CSR for one, list them.
The public host name
This is the name users see on the sign-in page and that appears in token issuers, such as auth.example.com. In Keycloak it is set with the hostname option. It must be in the certificate.
A separate admin host name
Keycloak can serve the admin console on a different host name with the hostname-admin option, often reachable only from an internal network. If that host is served over TLS with the same certificate, its name belongs in the SAN list too.
Old names during a migration
When moving an identity server to a new domain, the certificate may need to cover both the old and new names for a while, so redirects and old links keep working without warnings.
Wildcards
A wildcard such as *.example.com covers one level of subdomains, so auth.example.com but not a.b.example.com and not example.com itself. Wildcards are convenient but spread one private key across many services; a certificate per service limits the damage if a key leaks.
Choosing the key for a CSR
| Key | Notes |
|---|---|
| RSA 2048 | Works everywhere. The accepted minimum. |
| RSA 3072 or 4096 | Longer margin; slightly slower TLS handshakes. |
| EC P-256 | Smaller and faster; supported by all current clients. |
| EC P-384 | For policies that require 192-bit strength. |
Generate a new key for each certificate request rather than reusing an old key. Renewal is a natural moment to rotate.
Common CSR mistakes
- No SAN extension, so browsers reject the certificate.
- A typo in a host name. The CA issues exactly what you asked for.
- Losing the private key after sending the CSR. The certificate is useless without it; you must start again.
- Generating the key and CSR on a laptop and copying the key to the server, instead of generating on the server.
- Putting a challenge password in the CSR and thinking it protects the key. It does not; it is a legacy attribute some CAs used for revocation requests.
- Using SHA-1 for the CSR signature with very old tools.
Security notes
The CSR is public, but the private key it was made with is the most sensitive file in the process. Create it on the machine that will use it, restrict its file permissions, and never email it or paste it anywhere.
If a CSR or certificate was issued for the wrong names, do not use it. Request a correct one; for a public certificate, consider revoking the wrong one.
For automated renewals, ACME clients such as those used with Let’s Encrypt create a fresh key and CSR for you each time. That is the simplest way to keep up with ever shorter certificate lifetimes.
Best practices
- Generate keys and CSRs on the server that will use them.
- Always include every host name as a SAN, even if it repeats the CN.
- Use RSA 2048 or larger, or EC P-256, with a SHA-256 signature.
- Decode every CSR before you submit it.
- Automate issuance and renewal where the CA supports ACME.
After the certificate arrives
The CA returns a certificate, usually with one or more intermediate certificates. A few checks before installing it save an outage.
- Decode the certificate with the certificate decoder and confirm the names and validity.
- Confirm it matches your private key: the public key in the certificate must equal the one in your CSR.
- Build the chain file: your certificate first, then the intermediates in order.
- Install the certificate, chain and key, reload the server, and test with a browser and with
openssl s_client. - Put the expiry date in your monitoring.
# These two lines must print the same hash
openssl x509 -in cert.pem -noout -pubkey | openssl sha256
openssl pkey -in private.key -pubout | openssl sha256