A Request Asks for a Signature
A certificate request holds a subject and a public key and is signed with the matching private key; the command that checks it uses the public key inside the request, and a changed subject makes the check fail.
The question
A CA does not make a key for the one who wants a certificate. The requester makes a key pair and sends a request: a subject and the public key. What is in such a request, what is it signed with, and what does the CA learn from the signature?
The keys of this book are test material, 512-bit RSA, a toy size far too small to use.
Work it by hand
A certificate request is a SEQUENCE of three parts, like a certificate: the request information, the signature algorithm and the signature. The request information has a version, here 0, the subject, the public key and a list of attributes, here empty. The request of the intermediate is 255 bytes in DER.
The signature is made over the request information with the requester's private key and can be checked with the public key inside the request. So the request shows that whoever made it holds the private key; this reading is stated here, and the command below runs the check. The CA is not obliged to trust the subject the requester wrote.
The command req -noout -verify checks that signature; with -subject it prints the subject.
Run it
The demo is one command (line 3): req -in in/csr.txt -noout -verify -subject reads the request of the intermediate certificate of the example chain. It prints two lines: Certificate request self-signature verify OK and the subject, O=Example Test Lab, CN=Example Test Intermediate CA.
You can put another request in in/csr.txt. Measured: after one byte of the subject is changed, the command prints nothing on standard output, writes Warning: CSR self-signature does not match the contents and Certificate request self-signature verify failure to the error stream and ends with exit status 1, and this page then shows a failure.

Public test material, generated for this lesson. Never use it for anything real.
# Checks the signature of a request and prints its subject.
# Check runs it with other requests in in/csr.txt.
openssl req -in in/csr.txt -noout -verify -subject
{
"answer": "Certificate request self-signature verify OK\nsubject=O=Example Test Lab, CN=Example Test Intermediate CA"
}Your turn
Write one command that makes the certificate request for the key in in/key.txt, with the subject from the configuration in in/conf.txt (it fixes CN=requester.example.test), signed with SHA-256, and writes it to out.csr in PEM form. The command below is a starting point. Check runs it with other keys in in/key.txt and on five others.

Public test material, generated for this lesson. Never use it for anything real.
# Writes the certificate request to out.csr.
# Check runs it with other keys in in/key.txt.
openssl req -new -key in/key.txt -config in/conf.txt -sha256 \
-outform DER -out out.csr
{
"answer": "3081db3081860201003021311f301d06035504030c167265717565737465722e6578616d706c652e74657374305c300d06092a864886f70d0101010500034b003048024100b733977333ebe212bb82378a599ee997192650e5d66b927e61e5b59a98ba852322e2f89c0474660f3ae2bf99345caea437da082ded041b00cd83ac8fd44ba6b30203010001a000300d06092a864886f70d01010b0500034100b0ed502491a508a3f247818d3aa7cb16664ef23560ecc5bd7bc133a54efc4df615ae134f5dfd6e501722b0c236458b6cc3d55d86068ec5ceb85cfb8966c43088",
"file": "out.csr",
"bytes": 222
}Write one openssl command that makes a certificate request for the RSA key in in/key.txt, with the subject from the configuration in in/conf.txt, signed with SHA-256, and writes it to out.csr in PEM form. Check runs your command with other keys in in/key.txt.
Read the result carefully
The request makes no promise: a CSR can also carry requested extensions, which the CA may copy or ignore; the next lesson shows what the signing command does with them. The check above proves only that the signature fits the contents, not that the subject is true.
The kit does not allow an argument that starts with a slash, so the subject is given by a configuration text and not by -subj; measured on the intermediate, the request made this way is identical to the committed file. The page does not show how a real CA checks who is asking.
Recap
- A request holds a version, a subject, a public key and attributes, signed with the matching private key.
req -verifychecks the request's own signature with the key inside it.- A changed subject makes that check fail.
- The signature does not make the subject true; the CA decides what to put in the certificate.