cedric5

cedric5

Httpoison post request returns %HTTPoison.Error{id: nil, reason: {:tls_alert, 'internal error'}}}

Hello I am a beginner in Elixir and I’m currently running into the following issue.

When trying to make a post request to a server using httpoison.

  def send(xml_message) do
    url = "https://******/LIMessageProcessing/http/UICCCMessageProcessing/UICCCMessageProcessingInboundWS"
    response = HTTPoison.post(url ,[], hackney: [:insecure])
    req = Poison.decode!(response.body)
  end

I recieve the following error:

[info] ['TLS', 32, 'client', 58, 32, 73, 110, 32, 115, 116, 97, 116, 101, 32, 'certify', 32, 'at ssl_handshake.erl:364 generated CLIENT ALERT: Fatal - Internal Error - {unexpected_error,{case_clause,{error,{asn1,{...}}}}}', 10]
[info] Sent 500 in 126ms
[error] #PID<0.924.0> running TaftapServiceWeb.Endpoint (connection #PID<0.923.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: POST /
** (exit) an exception was raised:
    ** (ArgumentError) argument error
        :erlang.apply({:error, %HTTPoison.Error{id: nil, reason: {:tls_alert, 'internal error'}}}, :body, [])

No matter what options I pass to the post method it will always return this error.

If posting to another url (e.g https://google.com/)
I get the following error:

 (exit) an exception was raised:
    ** (ArgumentError) argument error
        :erlang.apply({:error, %HTTPoison.Error{id: nil, reason: :nxdomain}}, :body, [])

Using HTTPoison.get on https://google.com/ works but using get on the domain I want to post to yields the same {:tls_alert, ‘internal error’}}}.

I am sure that the server I am trying to post to functions as it should be as I have been able to make succesful requests from SAOP UI and Ruby.

Elixir version: 1.8.1
Erlang version: 21.2.6

Most Liked

voltone

voltone

[info] [‘TLS’, 32, ‘client’, 58, 32, 73, 110, 32, 115, 116, 97, 116, 101, 32, ‘certify’, 32, ‘at ssl_handshake.erl:364 generated CLIENT ALERT: Fatal - Internal Error - {unexpected_error,{case_clause,{error,{asn1,{…}}}}}’, 10]

This is a decoding error during the TLS handshake. The specific location (ssl_handshake.erl:364) suggests a certificate sent by the server cannot be parsed. Does openssl s_client -connect ******:443 -servername ****** connect without errors?

%HTTPoison.Error{id: nil, reason: :nxdomain}}

This suggests the hostname could not be resolved. I suspect you simply had a typo in the URL at the time, or there was a problem with your Internet connection.

ananthakumaran

ananthakumaran

In my current work, we have some concept similar to webhook and we need to support servers which might not follow the latest standard. Every time we try to upgrade erlang OTP, we will find some new errors which used to work in the old version. So we do the config change dance once again and settle on a config that works best across all the servers. Last time it was related to chacha20 cipher, which was enabled by default and there seem to be multiple incompatible implementations out there. Debugging these kind of errors are real tricky as the ssl app mostly throws a generic error without much details.

{:tls_alert, ‘internal error’}

This usually means something goes wrong when it tries to establish ssl connection. You could use SSL Server Test (Powered by Qualys SSL Labs) to figure out what kind of versions are supported by your target server. Then you can play around with ssl:connect/3

iex(1)> :ssl.start()
:ok
iex(2)> :ssl.connect('null.badssl.com', 443, [])

timestamp=2019-03-01T11:46:26.123Z level=info  message= ['TLS', 32, 'client', 58, 32, 73, 110, 32, 115, 116, 97, 116, 101, 32, 'hello', 32, 'received SERVER ALERT: Fatal - Handshake Failure', 10]
{:error, {:tls_alert, 'handshake failure'}}
iex(3)> :ssl.connect('google.com', 443, [])
{:ok,
 {:sslsocket, {:gen_tcp, #Port<0.19>, :tls_connection, :undefined},
  [#PID<0.438.0>, #PID<0.437.0>]}}

Once you find the correct set of options that allows you to connect, you
could pass that to hackney

HTTPoison.post(url, body, headers, ssl: [verify: :verify_none])

Where Next?

Popular in Questions Top

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
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
Kagamiiiii
Student &amp; New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
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
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
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
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
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
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

We're in Beta

About us Mission Statement