← Back to section · Software & Developer Tools
The Certificate Toolchain: Where req, x509, and ca Each Stand
When handling certificates by hand, the easiest confusion is the division of labor among the req, x509, and ca subcommands. This article follows a certificate's lifecycle to make their boundaries clear: who generates the request, who processes the certificate, and who issues as a system.
A certificate’s life runs through several stages: generating a key, submitting a request, issuance, delivery, and subsequent management. OpenSSL’s command line has quite a few certificate-related subcommands, and the most common beginner confusion is this: req, x509, and ca all seem able to “produce a certificate” — which one should be used? The answer is that they stand at different stages of the lifecycle; choosing the wrong tool usually does not produce a command error, but a result that lacks fields, has no records, and is hard to maintain.
req: Standing at the Request Stage
req is short for “request”: it handles the PKCS#10 certificate signing request, the CSR. The typical flow is to generate a CSR together with (or for an existing) key, containing the subject name, the public key, and the extensions the requester wants written in, then hand the CSR to the issuer. req’s other common ability is one-step self-signing: give it the self-signing option and it skips the CSR delivery stage and directly produces a self-signed certificate — the trick behind most “just sign one quickly” operations in test environments.
Note that a self-signed certificate has the same issuer and subject; it proves only “possession of the corresponding private key” and constitutes no third-party trust. Deploying a self-signed certificate as if it were a formal certificate is the most common misuse in manual PKI.
x509: Standing at the Processing Stage
The x509 subcommand takes an existing certificate (or a CSR) as input and performs viewing and transformation. Its most common use is printing a certificate as readable text: subject, issuer, validity period, public key, and extension fields at a glance — this is what troubleshooting looks at first. Next is format conversion: converting between PEM and DER, extracting a certificate from a bundle format, and so on. It can also do limited processing of a certificate, such as renewing and re-signing in self-signed scenarios, or adding extension fields.
x509’s boundary is that it maintains no state. It does not know what it has signed before and keeps no record of where serial numbers came from. That is perfectly fine for processing a single certificate, but once issuance volume grows and ledgers and revocation management are needed, it is beyond its remit.
ca: Standing at the System Stage
The ca subcommand is a complete miniature certificate authority. It works according to the CA section designated in the configuration file: the locations of the root certificate and private key, the issuance policy (which fields must match), certificate validity, and extension templates are all written in configuration. It maintains state files: index.txt is the index database of issued certificates, recording each certificate’s serial number, validity, and revocation status; the serial file holds the next available serial number. It is because of this state that ca can guarantee unique serial numbers, generate revocation lists (together with crl-related tools), and answer the question “which certificates have I actually issued?”
The cost of this design is ceremony: the directory structure, initial files, and configuration sections must all be prepared first, and the first setup is considerably more troublesome than req self-signing. Its applicable scenarios are small-scale PKIs such as lab environments, internal systems, and teaching demonstrations; a real production CA needs hardware key protection, auditing, and a permission system — that is a different class of product, and the ca subcommand does not pretend to replace it.
The Lifecycle Continues: Verification, Revocation, and Renewal
Issuance is only the midpoint of a certificate’s lifecycle; the second half has three more jobs, each with its tool position. Verification belongs to the verify subcommand: give it a trust root and the chain to check, and it validates signatures, validity periods, and extension constraints level by level, reporting at which level a failure occurred and why — when troubleshooting a “the browser says the certificate is bad” report, the first step is to verify the chain standalone with verify, separating the problem from the server configuration.
Revocation depends on the issuance-stage ledger, which is exactly the dividing line between ca and the other two: only ca maintains the index database of issued certificates, so only it can mark a certificate as revoked and generate a distributable revocation list (CRL). Neither req nor x509 holds this state; certificates they issued leave you empty-handed when revocation is needed — which is why, even at small scale, if there is any revocation requirement you should use ca from the start rather than muddling through with self-signing.
Renewal has no dedicated command at the tool level; in essence it is “walk the request-and-issuance path again, with the original key or a new one.” The most common mistakes in manual flows are renewing only the certificate file while forgetting that the private key and certificate must pair, or producing a new certificate that omits the SAN extensions the old one carried. Recording the exact commands and parameters of every issuance, then replaying them at renewal with only the validity period changed, is the plainest and most effective discipline in manual PKI.
The second half of the lifecycle also has one high-frequency action: pair checking — whether a certificate and a private key actually belong together. Deploy certificate A with private key B and the service either fails to start or fails handshakes, with error messages that are often vague. The manual check is to extract the public key from the certificate and the public key corresponding to the private key and compare them — only if the two match is the pair correct. In OpenSSL’s toolchain, pkey extracts public-key information from the private-key side and x509 extracts it from the certificate side; put the two outputs together and compare. Doing this certificate by certificate matters especially at renewal with rekeying and at bulk certificate replacement; it costs far less time than troubleshooting after deployment.
Extension Fields: The Shared Pitfall of All Three
Whichever path you take, extension fields are the most error-prone part. Modern TLS certificates rely on the SAN (Subject Alternative Name) rather than the legacy CN to identify domain names, and the key usage and extended key usage (EKU) extensions decide where a certificate may be used. Writing extension templates in the configuration file suits repeated issuance; for one-off issuance, req and x509 in 3.x both support the -addext option to append extensions ad hoc (for example, adding a SAN entry) without changing the global configuration for a single certificate.
Compress the division of labor into one sentence: req handles requests and self-signing, x509 handles viewing and processing of a single certificate, and ca handles systematic issuance with a ledger. Pick the right stage, and most of the confusion in manual PKI disappears.
Tags: OpenSSLCertificatesPKICA