Speed

What OK Means

The line OK from verify says that a chain is well formed at one time, under the roots it was given, and for a purpose only if one was named; a signature check in the engine's language says even less, because it has no clock and no host name.

The question

After a chain of this book passes, the command prints OK. What exactly has been checked, and what has not? The same question for a program: a call that asks whether one certificate was signed by another says yes or no, but what does that yes include?

The certificates of this book are test material, 512-bit RSA keys, a toy size far too small to use.

Work it by hand

OK from verify says three things at once: a path was found from the leaf to a root in the trusted file, each issuer on it was allowed to issue (the previous lesson), and each certificate was inside its dates at the time of the check.

The purpose is checked only when the command is given one with -purpose: measured, a leaf that names only client authentication prints OK without it and error 26 at 0 depth lookup: unsuitable certificate purpose with -purpose sslserver. A passing OK says nothing about who owns the key, whether the certificate was revoked, or whether the root deserves to be trusted: the root is trusted because someone put it in the file.

The engine's own call, verify_with, checks less. It asks whether the signature of one certificate is made by the key of the other and nothing else. It has no clock, so an expired certificate passes; it has no host name, so the name is a separate call, matches_host.

The demo shows both with a leaf of the intermediate of the example chain that ends on 2027-01-01.

Run it

The demo is a program (lines 1 to 6): it parses the certificate leaf_pem and the CA certificate ca_pem, calls verify_with on the leaf (line 3), matches_host with the name in host (line 5) and not_after (line 6), and returns one text of three lines: signed by CA|true, matches www.example.test|true and not_after|2027-01-01T00:00:00Z.

Three lines returned by the program: signed by CA|true, matches www.example.test|true and not_after|2027-01-01T00:00:00Z.

Public test material, generated for this lesson. Never use it for anything real.

let leaf = ssl.parse_cert(leaf_pem);
let ca = ssl.parse_cert(ca_pem);
let answer = "signed by CA|" + str(leaf.verify_with(ca));
answer = answer + "\nmatches " + host + "|";
answer = answer + str(leaf.matches_host(host));
answer = answer + "\nnot_after|" + leaf.not_after();
{
  "answer": "signed by CA|true\nmatches www.example.test|true\nnot_after|2027-01-01T00:00:00Z"
}

You can change the host or the certificate. Measured with the command on the same leaf: verify -attime 1790000000 with the root and the intermediate prints OK, and -attime 1830000000 stops with error 10 at 0 depth lookup: certificate has expired, while the program above says true for both times, because it never asks the time.

Your turn

Write a program with three inputs, leaf and ca (PEM texts of test material) and host. Return a list of three texts: true or false for whether the leaf is signed by the key of ca, true or false for whether the leaf matches host, and the not-after time of the leaf as the call returns it. Judge it, and find the candidates that are right for every input. Check runs each candidate on the data shown and on six others.

The host name app.example.test and the list of three texts that the shown program returns.

Public test material, generated for this lesson. Never use it for anything real.

let cert = ssl.parse_cert(leaf);
let issuer = ssl.parse_cert(ca);
let answer = str_list();
answer.add(str(cert.verify_with(cert)));
answer.add(str(cert.matches_host(host)));
answer.add(cert.not_after());
{
  "answer": [
    "false",
    "true",
    "2036-01-01T00:00:00Z"
  ]
}

leaf and ca are PEM texts of certificates and host is a host name. Return a list of three texts: the text of the boolean for whether the leaf is signed by the key of ca (true or false), the text of the boolean for whether the leaf matches host (true or false), and the not-after time of the leaf as the certificate call returns it. Check runs your program on other certificates and hosts.

Read the result carefully

The program answers three questions and each one is separate: it does not build a path, it does not look at dates except to print one, and it does not check that ca is a CA. A root that signs itself passes as its own issuer. Checked by hand in the oracle: it verifies the signature with plain integer arithmetic and compares the host with the names of the certificate.

None of the checks here looks at revocation lists, online status, name constraints or certificate transparency, and no network is used. The key of the example CA is committed in a public repository, which no real CA does. A passing check is the start of a decision about trust. See A Certificate Chain Trusts a Root for the part that chooses the roots.

Recap

  • OK says that a path exists, each issuer may issue and the dates fit at the time given; the purpose is checked only when one is given.
  • It does not say anything about revocation, the owner of the key, or whether the root deserves trust.
  • The engine's verify_with checks a signature only: no dates, no names, no path.
  • The host name is a separate call, and the date is a separate value.