Skip to content

Instantly share code, notes, and snippets.

@andreionut
Created March 10, 2015 14:42
Show Gist options
  • Select an option

  • Save andreionut/03a20fb52e8666136f93 to your computer and use it in GitHub Desktop.

Select an option

Save andreionut/03a20fb52e8666136f93 to your computer and use it in GitHub Desktop.

Revisions

  1. andreionut created this gist Mar 10, 2015.
    26 changes: 26 additions & 0 deletions ssl_connect.ex
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    Elixir 1.0.2 Code:
    iex(1)> :inets.start
    :ok
    iex(2)> :ssl.start
    :ok
    iex(3)> :ssl.connect("gateway.sandbox.push.apple.com", 2195, [{:mode, :binary}, {:certfile, "/path_to_cert.pem"}], 30000)
    {:error, {:options, {:socket_options, [mode: :binary]}}}

    iex(5)> :ssl.connect("api.github.com", 443, [], 30000)
    {:error, {:options, {:socket_options, []}}}
    iex(7)> :ssl.connect("api.github.com", 443, [mode: :binary], 30000)
    {:error, {:options, {:socket_options, [mode: :binary]}}}

    Erlang 17.4 (same on 17.0 and 17.1)

    1> application:start(crypto), application:start(asn1), application:start(public_key), application:start(ssl).
    ok
    2> ssl:connect("gateway.sandbox.push.apple.com", 2195, [{mode, binary}, {certfile, "/path_to_cert.pem"}], 30000).
    {ok,{sslsocket,{gen_tcp,#Port<0.1215>,tls_connection,
    undefined},
    <0.51.0>}}
    3> ssl:connect("api.github.com", 443, [{mode, binary}], 30000).
    {ok,{sslsocket,{gen_tcp,#Port<0.903>,tls_connection,
    undefined},
    <0.48.0>}}