From 66842b68c769a315fe3c1f95c669e2e31d2d2d8f Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 3 Apr 2024 22:32:19 +0200 Subject: [PATCH] remove cstruct --- lib/ca_certs.ml | 6 +++--- lib/ca_certs.mli | 2 +- test/tests.ml | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/ca_certs.ml b/lib/ca_certs.ml index 1585a9a..cd6cbb8 100644 --- a/lib/ca_certs.ml +++ b/lib/ca_certs.ml @@ -55,7 +55,7 @@ let get_anchors () = let der_list = ref [] in match iter_on_anchors (fun der_cert -> - der_list := Cstruct.of_string der_cert :: !der_list) + der_list := der_cert :: !der_list) with | () -> Ok !der_list | exception Failure msg -> Error (`Msg msg) @@ -76,7 +76,7 @@ let rec map_m f l = let windows_trust_anchors () = let* anchors = get_anchors () in let* cert_list = map_m X509.Certificate.decode_der anchors in - Ok (X509.Certificate.encode_pem_multiple cert_list |> Cstruct.to_string) + Ok (X509.Certificate.encode_pem_multiple cert_list) let trust_anchors () = if Sys.win32 then windows_trust_anchors () @@ -134,7 +134,7 @@ let authenticator ?crls ?allowed_hashes () = when String.length line >= len_end && String.(equal (sub line 0 len_end) end_of_cert) -> ( let data = String.concat "\n" (List.rev (line :: lines)) in - match X509.Certificate.decode_pem (Cstruct.of_string data) with + match X509.Certificate.decode_pem data with | Ok ca -> (None, ca :: cas) | Error (`Msg msg) -> Log.warn (fun m -> m "Failed to decode a trust anchor %s." msg); diff --git a/lib/ca_certs.mli b/lib/ca_certs.mli index 41bbf9f..58f247b 100644 --- a/lib/ca_certs.mli +++ b/lib/ca_certs.mli @@ -1,6 +1,6 @@ val authenticator : ?crls:X509.CRL.t list -> - ?allowed_hashes:Mirage_crypto.Hash.hash list -> + ?allowed_hashes:Digestif.hash' list -> unit -> (X509.Authenticator.t, [> `Msg of string ]) result (** [authenticator ~crls ~allowed_hashes ()] detects the root CAs (trust diff --git a/test/tests.ml b/test/tests.ml index f276ed9..25e4cb1 100644 --- a/test/tests.ml +++ b/test/tests.ml @@ -973,7 +973,7 @@ let tests tas = let host = Domain_name.(of_string_exn name |> host_exn) and chain = Result.get_ok - (X509.Certificate.decode_pem_multiple (Cstruct.of_string data)) + (X509.Certificate.decode_pem_multiple data) in ( name, `Quick, @@ -984,7 +984,7 @@ let tests tas = let host = Domain_name.(of_string_exn name |> host_exn) and chain = Result.get_ok - (X509.Certificate.decode_pem_multiple (Cstruct.of_string data)) + (X509.Certificate.decode_pem_multiple data) in (name, `Quick, test_one ?time tas (Error (result host chain)) host chain)) err_tests @@ -1013,7 +1013,7 @@ let ta () = when String.length line >= len_end && String.(equal (sub line 0 len_end) end_of_cert) -> ( let data = String.concat "\n" (List.rev (line :: lines)) in - match X509.Certificate.decode_pem (Cstruct.of_string data) with + match X509.Certificate.decode_pem data with | Ok ca -> (None, ca :: cas) | Error (`Msg _) -> (None, cas)) | Some lines -> (Some (line :: lines), cas))