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

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
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
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New

Other popular topics Top

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
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
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement