Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The own_name field in epoch_data is a [`host] Domain_name.t as well. #438

Merged
merged 2 commits into from
Aug 2, 2021
Merged
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
5 changes: 0 additions & 5 deletions lib/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ type own_cert = [
type session_cache = SessionID.t -> epoch_data option
let sexp_of_session_cache _ = Sexplib.Sexp.Atom "SESSION_CACHE"

module Peer_name = struct
type t = [ `host ] Domain_name.t
let sexp_of_t t = Sexplib.Sexp.Atom (Domain_name.to_string t)
end

module Auth = struct
type t = X509.Authenticator.t
let sexp_of_t _ = Sexplib.Sexp.Atom "Authenticator"
Expand Down
2 changes: 1 addition & 1 deletion lib/core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ type epoch_data = {
own_random : Cstruct_sexp.t ;
own_certificate : Cert.t list ;
own_private_key : Priv.t option ;
own_name : string option ;
own_name : Peer_name.t option ;
master_secret : master_secret ;
session_id : SessionID.t ;
extended_ms : bool ;
Expand Down
3 changes: 1 addition & 2 deletions lib/handshake_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ let answer_client_hello_common state reneg ch raw =

alpn_protocol config ch >>| fun alpn_protocol ->

let own_name = match host with None -> None | Some h -> Some (Domain_name.to_string h) in
let group =
if Ciphersuite.ecdhe cipher then
ecc_group
Expand All @@ -311,7 +310,7 @@ let answer_client_hello_common state reneg ch raw =
client_random = ch.client_random ;
own_certificate = chain ;
own_private_key = priv ;
own_name = own_name ;
own_name = host ;
alpn_protocol = alpn_protocol
} in
{ session with
Expand Down
5 changes: 2 additions & 3 deletions lib/handshake_server13.ml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ let answer_client_hello ~hrr state ch raw =
if c' = cipher &&
match hostname, old_epoch.own_name with
| None, None -> true
| Some x, Some y -> Domain_name.equal x (Domain_name.of_string_exn y)
| Some x, Some y -> Domain_name.equal x y
| _ -> false
then
let now = cache.Config.timestamp () in
Expand Down Expand Up @@ -222,9 +222,8 @@ let answer_client_hello ~hrr state ch raw =
| _ -> Error (`Fatal `InvalidSession)) >>= fun (chain, priv) ->
alpn_protocol config ch >>= fun alpn_protocol ->
let session =
let own_name = match hostname with None -> None | Some x -> Some (Domain_name.to_string x) in
let common_session_data13 = { session.common_session_data13 with
own_name = own_name ; own_certificate = chain ;
own_name = hostname ; own_certificate = chain ;
own_private_key = Some priv ; alpn_protocol }
in
{ session with common_session_data13 }
Expand Down
2 changes: 1 addition & 1 deletion lib/state.ml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type common_session_data = {
received_certificates : Cert.t list ;
own_certificate : Cert.t list ;
own_private_key : Priv.t option ;
own_name : string option ;
own_name : Peer_name.t option ;
client_auth : bool ;
master_secret : master_secret ;
alpn_protocol : string option ; (* selected alpn protocol after handshake *)
Expand Down
2 changes: 1 addition & 1 deletion lwt/examples/echo_server_sni.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let serve_ssl port callback =
let handle ep channels addr =
let host = match ep with
| Ok data -> ( match data.Tls.Core.own_name with
| Some n -> n
| Some n -> Domain_name.to_string n
| None -> "no name" )
| Error () -> "no session"
in
Expand Down
2 changes: 1 addition & 1 deletion lwt/examples/resume_echo_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let serve_ssl port callback =
own_random = hex "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" ;
own_certificate = fst cert ;
own_private_key = Some (snd cert) ;
own_name = Some "tls13test.nqsb.io" ;
own_name = Some Domain_name.(host_exn (of_string_exn "tls13test.nqsb.io")) ;
master_secret = hex "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" ;
session_id = Cstruct.create 0 ;
extended_ms = true ;
Expand Down