gmile

gmile

Certifi issue / regression in Rebar3?

I am on this host in CircleCI, debugging a failing Elixir code. The code fails to make an API request to Stripe. Particularly, the HTTP library fails to verify the certificate of the requested host. The HTTP client in use is hackney. The error I am getting is this one:

16:25:45.892 [info] TLS :client: In state :certify at ssl_handshake.erl:1950 generated CLIENT ALERT: Fatal - Unknown CA

In pursue to answer a question “well, what would be the CAs the system knows about”? I got down to this – a call to the following function returns an empty list:

:certifi.cacerts()
# => []

After studying the contents of the function on GitHub, I see that it reads the contents of a file containing certificates. That file exists on the file system, and indeed it contains certificates:

/home/circleci/project/_build/test/lib/certifi/priv/cacerts.pem

Running a somewhat equivalent Elixir code on this host will read the certificate bytes into memory just fine:

:public_key.pem_decode(File.read!(:certifi.cacertfile())) |> Enum.map(& elem(&1, 1)) |> Enum.reverse()

I am now puzzled as to why :certify would not return a list of certificates.

I find myself unable to dig deeper, as it appears that the contents of the function is changed during the compilation time using parse_transform, specifically using using ct_expand.

Digging into parse_transform, I see that there’s a way to get details about the kind of transform performed by enabling tracing:

A debugging facility exists: passing the option {ct_expand_trace, Flags} as an option,
or adding a compiler attribute -ct_expand_trace(Flags) will enable a form of call trace.

Flags' can be ’ (no trace) or [F]', where F’ is c' (call trace), r’ (return trace), or `x’ (exception trace)'.

Would someone please assist me in understanding how to enable the tracing exactly? Do I need to modify a file in :certifi somewhere (which I can totally afford to do), or pass a compiler option in command line to iex/elixir/elixirc somehow?

I am able to reliable reproduce this very issue by entering iex -S mix shell, and calling a dummy function Stripe.PaymentIntent.create(%{}).

Trivia:

  • elixir version: 1.11.4 (released several hours ago)
  • erlang version: 23.0 (erts-11.1)
  • hackney version: 1.17.0
  • certifi version: 2.5.3

Marked As Solved

axelson

axelson

Scenic Core Team

Have you tried the latest version of Hackney and Certifi?

Certifi 2.6.1 was released today:

Erlang Certifi 2.6.1, providing SSL Mozilla CA bundles to your application has been released with updated certificates and compatibility with OTP >= 23.

And Hackney 1.17.2 was also released today:

  • use parse_trans 3.3.1 only (fix compatibility with Erlang < 21)
  • bump certifi version
  • Allow merging of SSL opts

From: hackney/NEWS.md at master · benoitc/hackney · GitHub

They seem potentially related. Also I would upgrade from Erlang 23.0 to 23.2 although that probably won’t help this problem.

Also Liked

gmile

gmile

Running the following code in CircleCI containers for Elixir 1.11.3 and 1.11.4 depicts the issue:

mix local.rebar --force
wget -qO- https://github.com/certifi/erlang-certifi/archive/2.5.3.tar.gz | tar xvz
cd erlang-certifi-2.5.3
~/.mix/rebar3 compile
elixir -pa _build/default/lib/certifi/ebin -e "IO.inspect(:certifi.cacerts())"

Container with elixir 1.11.3 & rebar 3.13.1:

docker run -it cimg/elixir:1.11.3 sh -c 'mix local.rebar --force; wget -qO- https://github.com/certifi/erlang-certifi/archive/2.5.3.tar.gz | tar xvz; cd erlang-certifi-2.5.3; ~/.mix/rebar3 compile; elixir -pa _build/default/lib/certifi/ebin -e "IO.inspect(:certifi.cacerts())"'
# a list of binaries, suppressed for brevity

Container with elixir 1.11.4 & rebar 3.14.4:

docker run -it cimg/elixir:1.11.4 sh -c 'mix local.rebar --force; wget -qO- https://github.com/certifi/erlang-certifi/archive/2.5.3.tar.gz | tar xvz; cd erlang-certifi-2.5.3; ~/.mix/rebar3 compile; elixir -pa _build/default/lib/certifi/ebin -e "IO.inspect(:certifi.cacerts())"'
# => []

cimg/elixir is an image maintained by CircleCI, available here: Docker Hub.

gmile

gmile

In the 1.11.4 container, upgraded parse_trans (the only dependency of certifi) to 3.4.0. No luck, same result – empty list of certificates.

bram209

bram209

Thanks, I had a similar issue, after upgrading Certifi and Hackney to the latest versions (2.6.1 & 1.17.2) the issue seems to be resolved!

gmile

gmile

@axelson thank you! Versions you mention were not available at the time of me testing. We’ve upgraded, all good now :slight_smile:

Where Next?

Popular in Questions Top

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
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
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
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
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New

Other popular topics Top

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 30048 115
New
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
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
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
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
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 Postg...
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
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement