Skip to content

Commit

Permalink
Merge pull request #34 from mirage/tls.0.13.0
Browse files Browse the repository at this point in the history
Upgrade colombe to tls.0.13.0
  • Loading branch information
dinosaure authored Apr 16, 2021
2 parents 2d3e716 + 6ad7703 commit 2ffb955
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions sendmail-lwt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ depends: [
"sendmail" {= version}
"domain-name"
"lwt"
"tls"
"x509" {>= "0.7.0"}
"tls" {>= "0.13.0"}
"x509" {>= "0.12.0"}
"alcotest" {with-test}
]
2 changes: 1 addition & 1 deletion sendmail.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ depends: [
"ocaml" {>= "4.03.0"}
"dune" {>= "1.8"}
"colombe" {= version}
"tls"
"tls" {>= "0.13.0"}
"base64" {>= "3.0.0"}
"logs"
"emile" {>= "0.8" & with-test}
Expand Down
18 changes: 9 additions & 9 deletions sendmail/sendmail_with_starttls.ml
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ module Make_with_tls (Value : VALUE)
let raw = Cstruct.of_bytes buffer_with_tls ~off:0 ~len in

match Tls.Engine.handle_tls state raw with
| `Ok (`Ok state, resp, data) ->
| Ok (`Ok state, resp, data) ->
fiber_read state resp data
| `Ok (`Eof, _resp, _data) ->
| Ok (`Eof, _resp, _data) ->
Fmt.failwith "Reach End-of-stream while handshake"
| `Fail (failure, `Response resp) ->
| Error (failure, `Response resp) ->
(go_to_failure failure <.> only_write_tls) (`Response (Some resp))
| `Ok (`Alert alert, resp, _data) ->
| Ok (`Alert alert, resp, _data) ->
(go_to_alert alert <.> only_write_tls) resp in

Read { k= k_handshake state; buffer= buffer_with_tls; off= 0; len= 0x1000; }
Expand Down Expand Up @@ -321,21 +321,21 @@ module Make_with_tls (Value : VALUE)
let raw = Cstruct.of_bytes ~off:0 ~len:n buffer_with_tls in

match Tls.Engine.handle_tls state raw with
| `Ok (`Ok state, `Response None, `Data data) ->
| Ok (`Ok state, `Response None, `Data data) ->
ctx.tls <- Some state ; fiber_read data
| `Ok (`Ok state, `Response resp, `Data data) ->
| Ok (`Ok state, `Response resp, `Data data) ->
ctx.tls <- Some state ; fiber_write data resp
| `Ok (`Eof, `Response resp, `Data data) ->
| Ok (`Eof, `Response resp, `Data data) ->
ctx.tls <- None ;
let rec go_to_eof = function
| Read { k; _ } -> k 0 (* emit end-of-stream *)
| Write { k; buffer; off; len; } ->
Write { k= go_to_eof <.> k; buffer; off; len; }
| v -> v in
go_to_eof (fiber_write data resp)
| `Fail (failure, `Response resp) ->
| Error (failure, `Response resp) ->
(go_to_failure failure <.> only_write_tls) (`Response (Some resp))
| `Ok (`Alert alert, `Response resp, `Data _) ->
| Ok (`Alert alert, `Response resp, `Data _) ->
(go_to_alert alert <.> only_write_tls) (`Response resp) in

Read { k; buffer= buffer_with_tls; off= 0; len= (Bytes.length buffer_with_tls); }
Expand Down

0 comments on commit 2ffb955

Please sign in to comment.