Skip to content

Commit

Permalink
Revert "112.24.03 ( fix janestreet#3 )"
Browse files Browse the repository at this point in the history
This reverts commit fbc2610.
  • Loading branch information
rgrinberg committed Nov 20, 2015
1 parent 09dada6 commit cc32f3b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 37 deletions.
33 changes: 12 additions & 21 deletions bindings/ffi_bindings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,6 @@ struct
end
end

(* Not using stubs here so we can use the ~stub: argument and not blow up on
systems with older OpenSSL that don't support TLS 1.1 and 1.2. This way
Ctypes will guess sizes of types instead of getting them directly from C, but
since these types only use void and *void this should be fine.
https://github.com/janestreet/async_ssl/issues/3
*)
module Ssl_method = struct
let foreign = Foreign.foreign ~stub:true
let ssl_method_t = Ctypes.(void @-> returning (ptr void))
let sslv3 = foreign "SSLv3_method" ssl_method_t
let tlsv1 = foreign "TLSv1_method" ssl_method_t
let tlsv1_1 = foreign "TLSv1_1_method" ssl_method_t
let tlsv1_2 = foreign "TLSv1_2_method" ssl_method_t
let sslv23 = foreign "SSLv23_method" ssl_method_t
(* SSLv2 isn't secure, so we don't use it. If you really really really need it, use
SSLv23 which will at least try to upgrade the security whenever possible.
let sslv2_method = foreign "SSLv2_method" ssl_method_t
*)
end

module Bindings (F : Cstubs.FOREIGN) =
struct
Expand All @@ -83,6 +62,18 @@ struct
let ssl_load_error_strings = foreign "SSL_load_error_strings"
Ctypes.(void @-> returning void)

let ssl_method_t = Ctypes.(void @-> returning (ptr void))
let sslv3_method = foreign "SSLv3_method" ssl_method_t
let tlsv1_method = foreign "TLSv1_method" ssl_method_t
let tlsv1_1_method = foreign "TLSv1_1_method" ssl_method_t
let tlsv1_2_method = foreign "TLSv1_2_method" ssl_method_t
let sslv23_method = foreign "SSLv23_method" ssl_method_t
(* SSLv2 isn't secure, so we don't use it. If you really really really need it, use
SSLv23 which will at least try to upgrade the security whenever possible.
let sslv2_method = foreign "SSLv2_method" ssl_method_t
*)

module Ssl_ctx =
struct
let t = Ctypes.(ptr void)
Expand Down
22 changes: 10 additions & 12 deletions src/ffi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ open Import
module Types = Async_ssl_bindings.Ffi_bindings.Types(Ffi_generated_types)
module Bindings = Async_ssl_bindings.Ffi_bindings.Bindings(Ffi_generated)

module Ssl_method = Async_ssl_bindings.Ffi_bindings.Ssl_method

module Ssl_error = struct
type t =
| Zero_return
Expand Down Expand Up @@ -115,11 +113,11 @@ module Ssl_ctx = struct
let ver_method =
let module V = Version in
match ver with
| V.Sslv3 -> Ssl_method.sslv3 ()
| V.Tlsv1 -> Ssl_method.tlsv1 ()
| V.Tlsv1_1 -> Ssl_method.tlsv1_1 ()
| V.Tlsv1_2 -> Ssl_method.tlsv1_2 ()
| V.Sslv23 -> Ssl_method.sslv23 ()
| V.Sslv3 -> Bindings.sslv3_method ()
| V.Tlsv1 -> Bindings.tlsv1_method ()
| V.Tlsv1_1 -> Bindings.tlsv1_1_method ()
| V.Tlsv1_2 -> Bindings.tlsv1_2_method ()
| V.Sslv23 -> Bindings.sslv23_method ()
in
match Bindings.Ssl_ctx.new_ ver_method with
| None -> failwith "Could not allocate a new SSL context."
Expand Down Expand Up @@ -263,11 +261,11 @@ module Ssl = struct
let version_method =
let open Version in
match version with
| Sslv3 -> Ssl_method.sslv3 ()
| Tlsv1 -> Ssl_method.tlsv1 ()
| Tlsv1_1 -> Ssl_method.tlsv1_1 ()
| Tlsv1_2 -> Ssl_method.tlsv1_2 ()
| Sslv23 -> Ssl_method.sslv23 ()
| Sslv3 -> Bindings.sslv3_method ()
| Tlsv1 -> Bindings.tlsv1_method ()
| Tlsv1_1 -> Bindings.tlsv1_1_method ()
| Tlsv1_2 -> Bindings.tlsv1_2_method ()
| Sslv23 -> Bindings.sslv23_method ()
in
match Bindings.Ssl.set_method t version_method with
| 1 -> ()
Expand Down
4 changes: 0 additions & 4 deletions src/version.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ open Core.Std
[SSLv2] was banned by RFC 6176 which contains a dire list of its
shortcomings.
Older versions of OpenSSL do not support Tlsv1_1 and Tlsv1_2. You will be
able to link with such a version, but will get an error about an undefined
symbol at runtime if you try using the unsupported version.
*)
type t =
(* Sslv3 or above, historic name. *)
Expand Down

0 comments on commit cc32f3b

Please sign in to comment.