Skip to content

Commit

Permalink
Merge pull request #18 from hannesm/ci
Browse files Browse the repository at this point in the history
CI fixes, x509 0.13.0
  • Loading branch information
hannesm authored Apr 22, 2021
2 parents 9d1350b + e67947e commit f26a42a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 0.15.0
version = 0.18.0
profile=conventional
6 changes: 3 additions & 3 deletions ca-certs.opam
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ depends: [
"ptime"
"logs"
"mirage-crypto"
"x509" {>= "0.11.0"}
"ocaml" {>= "4.07.0"}
"x509" {>= "0.13.0"}
"ocaml" {>= "4.08.0"}
"alcotest" {with-test}
]
dev-repo: "git+https://github.com/mirage/ca-certs.git"
build: [
["dune" "subst"] {pinned}
["dune" "subst"] {dev}
[
"dune"
"build"
Expand Down
2 changes: 1 addition & 1 deletion ca-certs.opam.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build: [
["dune" "subst"] {pinned}
["dune" "subst"] {dev}
[
"dune"
"build"
Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
(name ca-certs)
(depends
astring bos fpath rresult ptime logs mirage-crypto
(x509 (>= 0.11.0))
(ocaml (>= 4.07.0))
(x509 (>= 0.13.0))
(ocaml (>= 4.08.0))
(alcotest :with-test))
(synopsis "Detect root CA certificates from the operating system")
(description
Expand Down
14 changes: 7 additions & 7 deletions lib/ca_certs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ let detect_one path =
| _ ->
Error
(`Msg
( "ca-certs: no trust anchor file found, looked into " ^ path ^ ".\n"
^ issue ))
("ca-certs: no trust anchor file found, looked into " ^ path ^ ".\n"
^ issue))

let detect_list paths =
let rec one = function
| [] ->
Error
(`Msg
( "ca-certs: no trust anchor file found, looked into "
^ String.concat ", " paths ^ ".\n" ^ issue ))
("ca-certs: no trust anchor file found, looked into "
^ String.concat ", " paths ^ ".\n" ^ issue))
| path :: paths -> (
match detect_one path with Ok data -> Ok data | Error _ -> one paths )
match detect_one path with Ok data -> Ok data | Error _ -> one paths)
in
one paths

Expand Down Expand Up @@ -95,7 +95,7 @@ let trust_anchors () =
Bos.OS.Cmd.(run_out cmd |> out_string |> success)
| s -> Error (`Msg ("ca-certs: unknown system " ^ s ^ ".\n" ^ issue))

let authenticator ?crls ?hash_whitelist () =
let authenticator ?crls ?allowed_hashes () =
let open Rresult.R.Infix in
trust_anchors () >>= fun data ->
let time () = Some (Ptime_clock.now ()) in
Expand All @@ -119,4 +119,4 @@ let authenticator ?crls ?hash_whitelist () =
let cas = List.rev cas in
match cas with
| [] -> Error (`Msg ("ca-certs: empty trust anchors.\n" ^ issue))
| _ -> Ok (X509.Authenticator.chain_of_trust ?crls ?hash_whitelist ~time cas)
| _ -> Ok (X509.Authenticator.chain_of_trust ?crls ?allowed_hashes ~time cas)
8 changes: 4 additions & 4 deletions lib/ca_certs.mli
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
val authenticator :
?crls:X509.CRL.t list ->
?hash_whitelist:Mirage_crypto.Hash.hash list ->
?allowed_hashes:Mirage_crypto.Hash.hash list ->
unit ->
(X509.Authenticator.t, [> `Msg of string ]) result
(** [authenticator ~crls ~hash_whitelist ()] detects the root CAs (trust
(** [authenticator ~crls ~allowed_hashes ()] detects the root CAs (trust
anchors) in the operating system's trust store using {!trust_anchors}. It
constructs an authenticator with the current timestamp {!Ptime_clock.now},
and the provided [~crls] and [~hash_whitelist] arguments, to be used for
{!Tls.Config.client}.
and the provided [~crls] and [~allowed_hashes] arguments. The resulting
authenticator can be used for {!Tls.Config.client}.
Returns [Error `Msg msg] if detection did not succeed. *)

val trust_anchors : unit -> (string, [> `Msg of string ]) result
Expand Down

0 comments on commit f26a42a

Please sign in to comment.