Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lwt-unix/gluten_lwt_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ module Server = struct
module TLS = struct
include Gluten_lwt.Server (Tls_io.Io)

let create_full ?ciphers ?version ?signature_algorithms ?reneg ?certificates ?acceptable_cas ?authenticator ?alpn_protocols ?zero_rtt ?ip client_addr socket =
Tls_io.make_full_server ?ciphers ?version ?signature_algorithms ?reneg ?certificates ?acceptable_cas ?authenticator ?alpn_protocols ?zero_rtt ?ip client_addr socket
let create_default ?alpn_protocols ~certfile ~keyfile =
let make_tls_server =
Tls_io.make_server ?alpn_protocols ~certfile ~keyfile
Expand All @@ -107,6 +109,8 @@ module Client = struct
module TLS = struct
include Gluten_lwt.Client (Tls_io.Io)

let create_full authenticator ?peer_name ?ciphers ?version ?signature_algorithms ?reneg ?certificates ?alpn_protocols ?ip socket =
Tls_io.make_full_client authenticator ?peer_name ?ciphers ?version ?signature_algorithms ?reneg ?certificates ?alpn_protocols ?ip socket
let create_default ?alpn_protocols socket =
Tls_io.make_client ?alpn_protocols socket
end
Expand Down
28 changes: 28 additions & 0 deletions lwt-unix/gluten_lwt_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ module Server : sig
with type socket = Tls_io.descriptor
and type addr = Unix.sockaddr

val create_full
: ?ciphers:Tls.Ciphersuite.ciphersuite list
-> ?version:(Tls.Core.tls_version * Tls.Core.tls_version)
-> ?signature_algorithms:Tls.Core.signature_algorithm list
-> ?reneg:bool
-> ?certificates:Tls.Config.own_cert
-> ?acceptable_cas:X509.Distinguished_name.t list
-> ?authenticator:X509.Authenticator.t
-> ?alpn_protocols:string list
-> ?zero_rtt:int32
-> ?ip:Ipaddr.t
-> Unix.sockaddr
-> Lwt_unix.file_descr
-> socket Lwt.t

val create_default
: ?alpn_protocols:string list
-> certfile:string
Expand Down Expand Up @@ -74,6 +89,19 @@ module Client : sig
module TLS : sig
include Gluten_lwt.Client with type socket = Tls_io.descriptor

val create_full
: X509.Authenticator.t
-> ?peer_name:[ `host ] Domain_name.t
-> ?ciphers:Tls.Ciphersuite.ciphersuite list
-> ?version:(Tls.Core.tls_version * Tls.Core.tls_version)
-> ?signature_algorithms:Tls.Core.signature_algorithm list
-> ?reneg:bool
-> ?certificates:Tls.Config.own_cert
-> ?alpn_protocols:string list
-> ?ip:Ipaddr.t
-> Lwt_unix.file_descr
-> socket Lwt.t

val create_default
: ?alpn_protocols:string list
-> Lwt_unix.file_descr
Expand Down
30 changes: 30 additions & 0 deletions lwt-unix/tls_io.real.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,42 @@ struct
let shutdown_receive _tls = ()
end

let make_full_client authenticator ?peer_name ?ciphers ?version ?signature_algorithms ?reneg ?certificates ?alpn_protocols ?ip socket =
let config = Tls.Config.client
~authenticator:authenticator
?peer_name
?ciphers
?version
?signature_algorithms
?reneg
?certificates
?alpn_protocols
?ip
() in
Tls_lwt.Unix.client_of_fd config socket

let null_auth ?ip:_ ~host:_ _ = Ok None

let make_client ?alpn_protocols socket =
let config = Tls.Config.client ?alpn_protocols ~authenticator:null_auth () in
Tls_lwt.Unix.client_of_fd config socket

let make_full_server ?ciphers ?version ?signature_algorithms ?reneg ?certificates ?acceptable_cas ?authenticator ?alpn_protocols ?zero_rtt ?ip _client_addr socket =
let config = Tls.Config.server
?ciphers
?version
?signature_algorithms
?reneg
?certificates
?acceptable_cas
?authenticator
?alpn_protocols
?zero_rtt
?ip
()
in
Tls_lwt.Unix.server_of_fd config socket

let make_server ?alpn_protocols ~certfile ~keyfile socket =
X509_lwt.private_of_pems ~cert:certfile ~priv_key:keyfile
>>= fun certificate ->
Expand Down