-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use HEX_CACERTS_PATH environment variable to allow custom override of system defined CA certificates #13504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use HEX_CACERTS_PATH environment variable to allow custom override of system defined CA certificates #13504
Conversation
Allow specifying a custom cacertfile for mix operations that need to make HTTPS requests. This allows mix operations to run in corporate environments that have a managed network with an SSL proxy that requires use of a custom cert file instead of the system default.
Maybe we should use HEX_CACERTS_PATH, since that’s what Hex uses anyway so it is fewer stuff to set? cc @ericmj |
@josevalim that would make sense. From what I can tell Rebar also has it's own separate mechanism for setting this when it's installed via it's config file. |
Ok, once it is pushed we will merge. :) |
@josevalim have updated to use Have manually tested on work laptop with managed SSL proxy (Zscaler) , and personal laptop without, and both work as expected 👍 |
Co-authored-by: Jean Klingler <[email protected]>
💚 💙 💜 💛 ❤️ |
We have been considering deprecating If you are in environment that requires custom certs presumably they are already installed with the system certs so I don't think any extra configuration is needed. @madlep Is there any reason why your custom certs are not installed in the system store? |
With the way IT/security has got our laptops setup, they're installed in the Regular web access and desktop apps are ok with that. For CLI apps - it's hit and miss. Some work fine, others need some environment flag or config set for them to be able to make HTTPS calls. So any HTTPS access via Elixir/Erlang is blocked unless the cert file is explicitly set when setting up the request in code. If I run the following, I can see 149 certs configured in Wondering if that's something that could be looked at upstream in the Erlang :public_key.cacerts_get()
|> Enum.map(fn {:cert, _der, otp} -> otp end)
|> Enum.map(fn {:OTPCertificate, tbs_cert, _sig_alg, _sig} -> tbs_cert end)
|> Enum.map(fn {:OTPTBSCertificate, _v, _sn, _sig, issuer, _val, _subj, _subjpki, _issid, _subid, _exts} -> issuer end)
|> Enum.map(fn {:rdnSequence, attrs} ->
attrs
|> Enum.sort()
|> Enum.find_value(fn
[{:AttributeTypeAndValue, {2,5,4,3}, value}] -> value
[{:AttributeTypeAndValue, {2,5,4,11}, value}] -> value
_ -> nil
end) || attrs
end)
|> Enum.map(fn {_, val} -> to_string(val) end)
|> Enum.sort_by(&String.upcase/1)
|> Enum.each(&IO.inspect/1) |
@ericmj Yup. Looks like it's hardcoded to just check the Will have a look at if it makes sense to check other keychains there too. That might be a future option if it can be changed in the Erlang stdlib. |
Allow specifying a custom cacertfile for mix operations that need to make HTTPS requests. This allows mix operations to run in corporate environments that have a managed network with an SSL proxy that requires use of a custom cert file instead of the system default.
On managed network with SSL proxy
Without environment variable on work laptop:
With environment variable enabled on work laptop:
On regular connection
On personal laptop, without need for custom CA cert file