File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -654,13 +654,31 @@ defmodule Mix.Utils do
654654 headers = [ { 'user-agent' , 'Mix/#{ System . version ( ) } ' } ]
655655 request = { :binary . bin_to_list ( path ) , headers }
656656
657+ # Use the system certificates if available, otherwise skip peer verification
658+ # TODO: Always use system certificates when OTP >= 25 is required
659+ ssl_options =
660+ if Code . ensure_loaded? ( :public_key ) and function_exported? ( :public_key , :cacerts_get , 0 ) do
661+ try do
662+ [ cacerts: apply ( :public_key , :cacerts_get , [ ] ) ]
663+ rescue
664+ _ ->
665+ msg =
666+ "warning: Failed to load system certificates. Falling back to skip SSL peer verification."
667+
668+ Mix . shell ( ) . error ( msg )
669+ [ verify: :verify_none ]
670+ end
671+ else
672+ [ verify: :verify_none ]
673+ end
674+
657675 # We are using relaxed: true because some servers is returning a Location
658676 # header with relative paths, which does not follow the spec. This would
659677 # cause the request to fail with {:error, :no_scheme} unless :relaxed
660678 # is given.
661679 #
662680 # If a proxy environment variable was supplied add a proxy to httpc.
663- http_options = [ relaxed: true ] ++ proxy_config ( path )
681+ http_options = [ relaxed: true , ssl: ssl_options ] ++ proxy_config ( path )
664682
665683 # Silence the warning from OTP as we verify the contents
666684 level = Logger . level ( )
You can’t perform that action at this time.
0 commit comments