And finally we can use it by decoding the certificates, and building a chain of trust we can build our Tls config with.
Here's an example of how to do it:
let decode_pem ca =
let ca = Cstruct.of_string ca in
let cert = X509.Certificate.decode_pem ca in
Result.get_ok cert
in
let cas = List.map decode_pem Ca_store.certificates in
let authenticator = X509.Authenticator.chain_of_trust ~time cas in
(* ... *)
Acknowledgements
This project would not be possible without ocaml-tls and ca-certs, in fact, we use ca-certs to generate the Ca_store.cas with code taken from the implementation of ca-certs.