···957957958958let ta () =
959959 let open Rresult.R.Infix in
960960- Ca_certs.trust_anchors () >>= fun data ->
961961- X509.Certificate.decode_pem_multiple (Cstruct.of_string data)
960960+ Ca_certs.trust_anchors () >>| fun data ->
961961+ (* we cannot use decode_pem_multiple since this fails on the first
962962+ undecodable certificate - while we'd like to stay operational, and ignore
963963+ some certificates *)
964964+ let sep = "-----END CERTIFICATE-----" in
965965+ let certs = Astring.String.cuts ~sep ~empty:false data in
966966+ let cas =
967967+ List.fold_left
968968+ (fun acc data ->
969969+ let data = data ^ sep in
970970+ match X509.Certificate.decode_pem (Cstruct.of_string data) with
971971+ | Ok ca -> ca :: acc
972972+ | Error _ -> acc)
973973+ [] certs
974974+ in
975975+ List.rev cas
962976963977let () =
964978 let tas = Rresult.R.get_ok (ta ()) in