···171171 Log.warn (fun m -> m "Ignored %u trust anchors." err_count);
172172 tas
173173174174+(* Domain-safe module-level cache for trust anchors to avoid repeated shell commands *)
175175+let cached_trust_anchors : string option Atomic.t = Atomic.make None
176176+177177+let trust_anchors_cached () =
178178+ match Atomic.get cached_trust_anchors with
179179+ | Some data -> Ok data
180180+ | None ->
181181+ let* data = trust_anchors () in
182182+ (* CAS to avoid races - if another domain populated it, use theirs *)
183183+ ignore (Atomic.compare_and_set cached_trust_anchors None (Some data));
184184+ Ok data
185185+174186let authenticator ?crls ?allowed_hashes () =
175175- let* data = trust_anchors () in
187187+ let* data = trust_anchors_cached () in
176188 match decode_pem_multiple data with
177189 | [] -> Error (`Msg ("ca-certs: empty trust anchors.\n" ^ issue))
178190 | cas ->