karang

karang

HTTPoison post request Handshake Failure

I am getting the following error:

iex(16)> HTTPoison.post("https://myserver.com/api/v1.1.0/login",'{ "username": "myusername","password": "somepassword,"port": "80"}',[hackney: [ssl: [cacertfile: '/usr/local/share/ca-certificates/extra/RootCA.crt']]])   

14:54:26.183 [info]  TLS :client: In state :hello received SERVER ALERT: Fatal - Handshake Failure
 
{:error,
 %HTTPoison.Error{
   id: nil,
   reason: {:tls_alert,
    {:handshake_failure,
     'TLS client: In state hello received SERVER ALERT: Fatal - Handshake Failure\n '}}
 }}

We have a local RootCA.crt file which I have added to the OS and makes it so I can make a request with no problems. I am able to make this request in postman as well as from Python but not in Elixir. Perhaps my syntax is wrong or I don’t understand ssl properly (that’s definitely true!). This server is not accessible to the internet. I can provide more information if necessary. Thanks for any help!

Marked As Solved

karang

karang

I solved this problem today like this:

HTTPoison.post("http://myserver.com/api/v1.1.0/login",'{ "username": "myusername","password": "somepassword,"port": "80"}',hackney: [:insecure])

I passed the insecure option to hackney and changed the https to http. I know this is not recommended but I need to login and I don’t have access to the SSL settings on the server.

Also Liked

akash-akya

akash-akya

Along with what @lucaong suggested, once you specify :ssl you have to specify all SSL options, hackney does not merge ssl options.

from hackney readme:

Note that ssl_options overrides all options passed to the ssl module.

lucaong

lucaong

Not sure this is the actual issue, but the HTTPoison README does not use the atom :hackney in the SSL options:

url = "https://example.org/api/endpoint_that_needs_client_cert"
options = [ssl: [certfile: "certs/client.crt"]]
{:ok, response} = HTTPoison.post(url, [], options)

Even when passing a :cacertfile, it seems to be passed directly under :ssl: httpoison/test/httpoison_test.exs at 19f04da7949bf32141b8c3ff354e260542e4dd52 · edgurgel/httpoison · GitHub

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130579 1222
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
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
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
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31525 112
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New

We're in Beta

About us Mission Statement