dvadell1

dvadell1

:ssl.connect() always returns :socket_options error!

Hi!

What is the right way of calling the :ssl.connect() ? From Erlang -- Using SSL application API it looks like it should be:

:ssl.start() 
:ssl.connect("google.com", 443, [{:verify, :verify_peer},{:cacerts, :public_key.cacerts_get()}])

But no matter what host or options I try, I get the same:


Interactive Elixir (1.14.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :ssl.start()                                                                                      
:ok
iex(2)> :ssl.connect("google.com", 443, [{:verify, :verify_peer}, {:cacerts, :public_key.cacerts_get()} ])
{:error,
 {:options,
  {:socket_options,
   [packet_size: 0, packet: 0, header: 0, active: false, mode: :binary]}}}

Does anyone know what am I doing wrong?
Thanks!

Marked As Solved

kip

kip

ex_cldr Core Team

Since :ssl is an erlang lib I expect you would need to put the URL in single quotes for Elixir, like 'google.com'. That may not be the source of the error you are seeing but it might help.

Also Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Yup

iex(3)> :ssl.connect("google.com", 443, [{:verify, :verify_peer},{:cacerts, :public_key.cacerts_get()}])
{:error,
 {:options,
  {:socket_options,
   [packet_size: 0, packet: 0, header: 0, active: false, mode: :binary]}}}
iex(4)> :ssl.connect('google.com', 443, [{:verify, :verify_peer},{:cacerts, :public_key.cacerts_get()}])
{:ok,
 {:sslsocket, {:gen_tcp, #Port<0.7>, :tls_connection, :undefined},
  [#PID<0.244.0>, #PID<0.243.0>]}}

It’s a common gotcha when transliterating code from Erlang to Elixir.

dvadell1

dvadell1

Thanks!! That was exactly it! :slight_smile:

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement