HTTPoison ssl_handshake issue

Hi All,

I am trying to get some data from another server using HTTPoison. But i am getting below error not sure how to fix it. Can anyone help me with this.

[info] TLS :client: In state :certify at ssl_handshake.erl:1893 generated CLIENT ALERT: Fatal - Bad Certificate

{:error,
 %HTTPoison.Error{
   id: nil,
   reason: {:tls_alert,
    {:bad_certificate,
     'TLS client: In state certify at ssl_handshake.erl:1893 generated CLIENT ALERT: Fatal - Bad Certificate\n'}}
 }}

mix file (Elixir 1.11.2)

      {:phoenix, "~> 1.5.8"},
      {:phoenix_ecto, "~> 4.2.1"},
      {:ecto_sql, "~> 3.5.4"},
      {:postgrex, ">= 0.15.8"},
      {:phoenix_live_view, "~> 0.15.4"},
      {:floki, ">= 0.27.0", only: :test},
      {:phoenix_html, "~> 2.14.3"},
      {:phoenix_live_reload, "~> 1.3.0", only: :dev},
      {:phoenix_live_dashboard, "~> 0.4.0"},
      {:telemetry_metrics, "~> 0.6.0"},
      {:telemetry_poller, "~> 0.5.1"},
      {:gettext, "~> 0.18.2"},
      {:jason, "~> 1.2.2"},
      {:plug_cowboy, "~> 2.4.1"},
      {:httpoison, "~> 1.8.0"},
      {:xlsxir, "~> 1.6"},
      {:ecto_psql_extras, "~> 0.2"},
      {:elixlsx, "~> 0.4.2"},
      {:oban, "~> 2.4"},
      {:joken, "~> 2.3"},
      {:ex_aws, "~> 2.1.8"},
      {:ex_aws_s3, "~> 2.1"},
      {:hackney, "~> 1.17"},
      {:sweet_xml, "~> 0.6.6"},
      {:bamboo, "~> 2.0.0"},
      {:bamboo_smtp, "~> 4.0"},

If you are really in a hurry you can skip SSL verification altogether:

HTTPoison.post(param_1, param_2, ssl: [verify: :verify_none])

I do NOT recommend this though. You can try downgrading the TLS version because that’s very often a problem as well:

HTTPoison.post(param_1, param_2, ssl: [{:versions, [:'tlsv1.2']}])

If that doesn’t work, well, you might be better served if you try hitting your endpoint with curl and see more detailed errors that can help you narrow down the issue.

1 Like