Skip to content

Commit

Permalink
minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesm committed Aug 5, 2024
1 parent 9c957ad commit 053648f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 0.25.1
version = 0.26.2
profile=conventional
36 changes: 26 additions & 10 deletions lib/ca_certs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,35 @@ let trust_anchors () =
Bos.Cmd.(
v "security" % "find-certificate" % "-a" % "-p" % path)
in
Bos.OS.Cmd.(
run_out cmd |> out_string |> success |> Result.to_option))
Bos.OS.Cmd.(run_out cmd |> out_string |> success))
|> List.fold_left
(fun acc cert ->
match (cert, acc) with
| Some cert, Some acc -> Some (cert ^ "\n" ^ acc)
| Some cert, None -> Some cert
| _ -> acc)
None
|> Option.to_result
~none:
(`Msg
("ca-certs: no trust anchor file found on macOS.\n" ^ issue))
| Ok cert, Ok acc -> Ok (cert ^ "\n" ^ acc)
| Ok cert, Error (`Msg msg) ->
Log.warn (fun m ->
m
"ignoring error %s (got another set of \
certificates)"
msg);
Ok cert
| Error e, Ok "" -> Error e
| Error (`Msg msg), Ok x ->
Log.warn (fun m ->
m
"ignoring error %s (already have another set of \
certificates)"
msg);
Ok x
| Error e, Error (`Msg msg) ->
Log.warn (fun m ->
m "ignoring error %s (got another error)" msg);
Error e)
(Ok "")
|> Result.map_error (function `Msg msg ->
`Msg
("ca-certs: no trust anchor file found on macOS: " ^ msg
^ ".\n" ^ issue))
| s -> Error (`Msg ("ca-certs: unknown system " ^ s ^ ".\n" ^ issue)))

let authenticator ?crls ?allowed_hashes () =
Expand Down

0 comments on commit 053648f

Please sign in to comment.