JFLib

netio/tls/staple.rs#

Source: lib/netio/tls/staple.rs

staple -- the OCSP responses a server staples (RFC 6066 8, RFC 8446 4.4.2.1)

  Staples::new()                    one store for all of a server's certificates
  staples.set(&chain, issuer, der)  a response for the leaf of `chain`, checked against it and
                                    its issuer (chain[1], or `issuer` when the chain has none)
  staples.get(&leaf) / response(&leaf) / remove(&leaf)
  netio::ocsp::refresh(&staples, &client, &chain, issuer)   fetches and sets when one is due

A server with ServerConfig::ocsp sends a client that asks (status_request) the current
response of the certificate it shows; one past its nextUpdate is not sent (and dropped).
/// the longest response kept (responses are a few KiB; one with a responder certificate and
/// an RSA signature under 4 KiB)
MAX_STAPLE: usize = 32 * 1024
  • struct Staples OCSP responses by certificate (SHA-256 of the leaf's DER)

impl Staples

  • fn new() -> Staples
  • fn now(&self) -> i64 Unix seconds (tests shift the clock: test_shift)
  • fn test_shift(&self, secs: i64)
  • fn test_insert(&self, leaf: &[u8], der: Vec<u8>) (tests) keep any bytes for a leaf, unchecked, current for a day
  • fn set(&self, chain: &[Vec<u8>], issuer: Option<&Cert>, der: Vec<u8>) -> Result<Response, String> keep der for the leaf of chain (DER, leaf first): checked against the leaf and its issuer (issuer, which must have signed the leaf, else the certificate of the chain that did) and current now. A revoked or unknown status is kept too (the server shows what its CA says). It is stapled until it expires (Response::expires: also the end of a delegated responder's certificate). -> the response read
  • fn get(&self, leaf: &[u8]) -> Option<Arc<Vec<u8>>> the response to staple for this leaf (DER): None when there is none or it is out of date (it is dropped then)
  • fn response(&self, leaf: &[u8]) -> Option<Response> what the kept response for this leaf says (also one out of date)
  • fn remove(&self, leaf: &[u8])
  • fn len(&self) -> usize
  • fn is_empty(&self) -> bool
  • fn clear(&self)

Source: docs/API.md in the JFLib repository.