JFLib

plat/certs.rs#

Source: lib/plat/certs.rs

certs -- the operating system's trusted certificate authorities

  verify_tls_server(chain, host, ocsp, extra, time) -> Option<Result<(), Refused>>
       Windows: CryptoAPI builds and checks the chain (leaf first, DER) for a TLS server of
       that name at that time (Unix seconds), with the machine's and user's roots, enterprise
       policy and automatic root updates (like for every program there, Windows may fetch a
       missing intermediate or root); the leaf's revocation from the stapled OCSP response
       (ocsp) and what Windows has cached, nothing fetched for it.  Where its roots give no
       path, once more with the extra CAs (DER: a company CA) as its only roots, nothing
       fetched.  macOS and iOS: the Security framework (SecTrustEvaluateWithError) with the
       system's and the user's roots and trust settings, the extra CAs as anchors beside them,
       and the stapled response, without network access.  Either way the system's policy
       applies to the extra CAs as well, and its answer is the whole answer.  Some(Err) says
       why the system refuses.  Linux: None (netio checks against the bundle, then the extra
       CAs).  Android: None as well (the same way with the system's CA folders).
  verify_tls_server_chain(chain, host, ocsp, extra, time) -> Option<Result<Vec<Vec<u8>>, Refused>>
       the same, and on a yes the chain the system built (DER, leaf first, up to the root or
       extra CA it trusts, a root the server left out included): Windows the first simple
       chain of CryptoAPI's chain context, Apple SecTrustCopyCertificateChain.  Linux,
       Android: None
  verify_tls_server_roots(chain, host, roots, time) -> Option<Result<(), Refused>>
       the same with only these CAs as trust anchors (DER), not the system's: nothing
       fetched, no revocation; the system's checks against a PKI of one's own
       (tools/limbo_check.py --system).  An empty host: no name checked.  Linux, Android: None.
  Refused { reason, text }   Reason: UnknownCa, Expired, Name, Revoked, Usage, Other; text:
       the system's own words (and its code)
  root_bundle() -> Option<Vec<u8>>
       Linux: PEM -- the file SSL_CERT_FILE names, else the distribution's CA bundle (Debian /
       Ubuntu, Fedora / RHEL, openSUSE, Alpine), and the files in the folders of SSL_CERT_DIR
       (':' between them), as OpenSSL takes the two; macOS: /etc/ssl/cert.pem; Android: the
       system's CA folder (/apex/com.android.conscrypt/cacerts, else
       /system/etc/security/cacerts; only the system's CAs).  Windows, iOS: None.
  • enum Reason why the system refused a server's chain

    • UnknownCa -- no path to a CA it trusts: a self-signed certificate, a CA of one's own, a missing intermediate
    • Expired -- a certificate of the chain has expired or is not valid yet
    • Name -- the certificate is not for this name
    • Revoked -- a certificate of the chain is revoked
    • Usage -- a certificate is not for a TLS server (its extended key usage)
    • Other -- another reason (the text says which)
  • struct Refused the system's refusal: the reason and the system's own words

    • reason: Reason
    • text: String

impl Refused

  • fn new(reason: Reason, text: impl Into<String>) -> Refused

  • fn root_bundle() -> Option<Vec<u8>> (Linux)

  • fn root_bundle() -> Option<Vec<u8>> (Windows)

/// the CA folders of Android, newest first: Conscrypt's APEX (Android 14 and later, updated with
/// Conscrypt), else the system image's
ANDROID_CA_DIRS: [&str; 2] = ["/apex/com.android.conscrypt/cacerts", "/system/etc/secu ...
  • fn root_bundle() -> Option<Vec<u8>> Android: the system's CAs (docs/ANDROID.md decision 6) -- the files of the first folder of ANDROID_CA_DIRS that has any, one certificate per file (its PEM, then a text dump), in the order of their names. The CAs the user installed stay out, as for every Android app since API 24 (Network Security Config); so do SSL_CERT_FILE and SSL_CERT_DIR

  • fn android_ca_dir() -> Option<&'static str> (Android) the folder root_bundle reads: the first of ANDROID_CA_DIRS with files in it

  • fn verify_tls_server(_chain: &[&[u8]], _host: &str, _ocsp: Option<&[u8]>, _extra: &[&[u8]], _time: i64) -> Option<Result<(), Refused>>

  • fn verify_tls_server_chain(_chain: &[&[u8]], _host: &str, _ocsp: Option<&[u8]>, _extra: &[&[u8]], _time: i64) -> Option<Result<Vec<Vec<u8>>, Refused>>

  • fn verify_tls_server_roots(_chain: &[&[u8]], _host: &str, _roots: &[&[u8]], _time: i64) -> Option<Result<(), Refused>>

  • fn verify_tls_server(chain: &[&[u8]], host: &str, ocsp: Option<&[u8]>, extra: &[&[u8]], time: i64) -> Option<Result<(), Refused>> (Windows)

  • fn verify_tls_server_chain(chain: &[&[u8]], host: &str, ocsp: Option<&[u8]>, extra: &[&[u8]], time: i64) -> Option<Result<Vec<Vec<u8>>, Refused>> (Windows)

  • fn verify_tls_server_roots(chain: &[&[u8]], host: &str, roots: &[&[u8]], time: i64) -> Option<Result<(), Refused>> (Windows)

  • fn root_bundle() -> Option<Vec<u8>> (Apple) macOS: the system's PEM bundle (/etc/ssl/cert.pem, updated with the system); iOS: None. Apple's own trust decision is verify_tls_server.

  • fn verify_tls_server(chain: &[&[u8]], host: &str, ocsp: Option<&[u8]>, extra: &[&[u8]], time: i64) -> Option<Result<(), Refused>> (Apple)

  • fn verify_tls_server_chain(chain: &[&[u8]], host: &str, ocsp: Option<&[u8]>, extra: &[&[u8]], time: i64) -> Option<Result<Vec<Vec<u8>>, Refused>> (Apple)

  • fn verify_tls_server_roots(chain: &[&[u8]], host: &str, roots: &[&[u8]], time: i64) -> Option<Result<(), Refused>> (Apple)

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