diff options
author | Ryan Kavanagh <rak@rak.ac> | 2020-06-12 22:23:19 -0400 |
---|---|---|
committer | Ryan Kavanagh <rak@rak.ac> | 2020-06-12 22:23:19 -0400 |
commit | aae2693a885158f11b348483e2bb66b38e5ac5ec (patch) | |
tree | f56f866aa11692735e6f58776a19578b7a90184f | |
parent | extended tlsUtils (diff) |
Use tlsutils to connect
Diffstat (limited to '')
-rw-r--r-- | gemini/geminiTransaction.ml | 7 | ||||
-rw-r--r-- | gemini/tlsUtils.ml | 10 | ||||
-rw-r--r-- | gemini/tlsUtils.mli | 4 |
3 files changed, 10 insertions, 11 deletions
diff --git a/gemini/geminiTransaction.ml b/gemini/geminiTransaction.ml index 27208b7..9f079af 100644 --- a/gemini/geminiTransaction.ml +++ b/gemini/geminiTransaction.ml @@ -233,11 +233,10 @@ struct ~message:"URL with no host?" in let port = Base.Option.value_exn (Uri.port r.url) ~message:"URL with no port?" in - let%lwt authenticator = r.authenticator in + let authenticator = r.authenticator in try%lwt - let%lwt (ic, oc) = Tls_lwt.connect_ext - Tls.Config.(client ~peer_name:host ~authenticator - ~ciphers:Ciphers.default ()) (host, port) in + let%lwt (ic, oc) = TlsUtils.TlsUtils.connect ~authenticator + ~peer_name:host (host, port) in let%lwt () = Lwt_io.write oc (Uri.to_string r.url ^ "\r\n") in let%lwt (_, parsed) = parse response_parser ic in Lwt.return parsed diff --git a/gemini/tlsUtils.ml b/gemini/tlsUtils.ml index b0d65ae..0a3f59d 100644 --- a/gemini/tlsUtils.ml +++ b/gemini/tlsUtils.ml @@ -1,12 +1,12 @@ module type TLS_UTILS = sig - type authenticator = X509_lwt.authenticator Lwt.t + type authenticator = X509_lwt.authenticator type ciphers = Tls.Ciphersuite.ciphersuite list type own_cert = Tls.Config.own_cert val null_auth : authenticator - val ca : Lwt_io.file_name -> authenticator + val ca : Lwt_io.file_name -> authenticator Lwt.t val self_sign : ?bits:int -> ?days:int -> X509.Distinguished_name.t @@ -19,11 +19,11 @@ end module TlsUtils : TLS_UTILS = struct - type authenticator = X509_lwt.authenticator Lwt.t + type authenticator = X509_lwt.authenticator type ciphers = Tls.Ciphersuite.ciphersuite list type own_cert = Tls.Config.own_cert - let null_auth = Lwt.return (fun ~host:_ -> fun _ -> Ok None) + let null_auth ~host:_ _ = Ok None let ca path = if Sys.is_directory path then X509_lwt.authenticator (`Ca_dir path) @@ -49,7 +49,7 @@ struct let peer_name = match peer_name with | Some name -> name | None -> host in - let%lwt authenticator = authenticator in + let authenticator = authenticator in Tls_lwt.connect_ext Tls.Config.(client ~peer_name:peer_name ~authenticator ~ciphers ~certificates:own_cert ()) (host, port) diff --git a/gemini/tlsUtils.mli b/gemini/tlsUtils.mli index a0d89ff..37f6ce5 100644 --- a/gemini/tlsUtils.mli +++ b/gemini/tlsUtils.mli @@ -1,12 +1,12 @@ module type TLS_UTILS = sig - type authenticator = X509_lwt.authenticator Lwt.t + type authenticator = X509_lwt.authenticator type ciphers = Tls.Ciphersuite.ciphersuite list type own_cert = Tls.Config.own_cert val null_auth : authenticator - val ca : Lwt_io.file_name -> authenticator + val ca : Lwt_io.file_name -> authenticator Lwt.t val self_sign : ?bits:int -> ?days:int -> X509.Distinguished_name.t |