Skip to content

Conversation

@moogle19
Copy link
Contributor

OTP26-rc2 changed the default behaviour of the http client from :verify_none to :verify_peer which results in following error when trying to install hex:

Mix requires the Hex package manager to fetch dependencies
Shall I install Hex? (if running non-interactively, use "mix local.hex --force") [Yn] 
** (Mix) httpc request failed with: {:failed_connect, [{:to_address, {~c"repo.hex.pm", 443}}, {:inet, [:inet], {:options, {:verify, {:missing_dep_cacertfile_or_cacerts}}}}]}

This PR fixes this, by explicitly defining :verify_none.

@josevalim
Copy link
Member

OTP 25 includes the system certificates as part of their distribution, so maybe we should use that instead?

@moogle19
Copy link
Contributor Author

Thought about that too, but doesn't Elixir 1.15 have OTP 24 as lowest compatible version?

Or should we add a :erlang.function_exported/3 check and use the system certificates if the function is available?

@moogle19
Copy link
Contributor Author

A little off-topic, but running :public_key.cacerts_get/0 in iex when using OTP 26.0 is oddly slow (takes ~10s for me).
erl with OTP 26 and iex with OTP 25 are instant.

@josevalim
Copy link
Member

Or should we add a :erlang.function_exported/3 check and use the system certificates if the function is available?

Let's do this.

A little off-topic, but running :public_key.cacerts_get/0 in iex when using OTP 26.0 is oddly slow (takes ~10s for me).
erl with OTP 26 and iex with OTP 25 are instant.

I will investigate.

@josevalim
Copy link
Member

josevalim commented Mar 22, 2023

@moogle19 isolated here: erlang/otp#7040

@moogle19
Copy link
Contributor Author

What should happen if the system has no certificates?
cacerts_get/0 says:

The function fails if no cacerts could be loaded.

Should we let it fail or also use :verify_none in that case?

@josevalim
Copy link
Member

@moogle19 let's emit a warning and fallback to verify none!

@josevalim josevalim closed this Mar 22, 2023
@josevalim josevalim reopened this Mar 22, 2023
@josevalim
Copy link
Member

Wrong button, sorry!

@josevalim
Copy link
Member

Hi @moogle19, please let me know if you want to do further refinements or if we should do it. My plan is to release a new v1.14 soon that works on 26 RC for those who want to try it out. :)

@moogle19
Copy link
Contributor Author

@josevalim
Sorry, didn't find the time to finish it yesterday.
I just added the warning, when the system certificates could not be loaded.

@josevalim
Copy link
Member

No need to be sorry, your contributions are very appreciated. :)

@josevalim josevalim merged commit 62de47f into elixir-lang:main Mar 23, 2023
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

josevalim pushed a commit that referenced this pull request Mar 23, 2023
@lhoguin
Copy link

lhoguin commented Apr 7, 2023

Hello! This is not enough. If you are going to verify the peer certificate, you also need to set the customize_hostname_check option with what public_key:pkix_verify_hostname_match_fun(https) returns. Otherwise certificates with wildcards will fail to match (like *.github.io or *.githubusercontent.com).

@lhoguin
Copy link

lhoguin commented Apr 7, 2023

Alternatively there is an httpc:ssl_verify_host_options(true) function that does both cacerts, customize_hostname_check and maybe a few more.

@josevalim
Copy link
Member

@lhoguin thank you, i will investigate. ❤️

@lhoguin
Copy link

lhoguin commented Apr 12, 2023

@josevalim Would you like me to open a new ticket so this doesn't get forgotten?

@josevalim
Copy link
Member

No need, i pushed to main already but forgot to follow up: 6f58a36

@lhoguin
Copy link

lhoguin commented Apr 12, 2023

Great, thanks. I will forward this info to the relevant developer so we can confirm it all works for us.

@lhoguin
Copy link

lhoguin commented Apr 12, 2023

That appears to solve all our Mix/Elixir related issues. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants