JFLib

netio/ocsp.rs#

Source: lib/netio/ocsp.rs

ocsp -- OCSP over HTTP (RFC 6960 A.1, RFC 5019): a certificate's status from its CA's
responder, and the stapled responses a server keeps current

  fetch(&client, &cert, &issuer) -> Result<(DER, Response), String>
                                  a POST of the request to the certificate's responder (its
                                  first http(s) OCSP URI), the answer checked
  refresh(&staples, &client, &chain, issuer) -> Result<i64, String>
                                  a server's staple for the leaf of `chain`: fetched when there
                                  is none or it is due, kept in `staples` (tls::Staples) ->
                                  when to call again (Unix seconds)

A server calls refresh for each of its certificates at start and then at the times it
returns; after an error again within the hour (the kept response serves until its
nextUpdate).  Responders speak plain http as a rule: the response is signed, the request
carries no secret (RFC 6960 A.1).
/// the longest answer taken from a responder
MAX_RESPONSE: usize = 64 * 1024
/// how soon refresh asks again after a failed fetch
RETRY_S: i64 = 3600
  • fn fetch(client: &Client, cert: &Cert, issuer: &Cert) -> Result<(Vec<u8>, Response), String> the status of cert from its CA's OCSP responder: the first http or https URI of its authority information access gets the request by POST; the answer must be a response that check takes now -> its DER (to staple) and what it says

  • fn refresh(staples: &Staples, client: &Client, chain: &[Vec<u8>], issuer: Option<&Cert>) -> Result<i64, String> keep the staple of the leaf of chain (DER, leaf first) current: fetched when there is none, it is due (Response::refresh_at) or out of date. issuer: the leaf's issuer when the chain does not hold it. -> when to call again (Unix seconds); Err: why the fetch failed (call again within RETRY_S: the kept response serves until it is out of date)

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