From d3e83b7a9e53fa03ffc6b274ec1cc570cc0e41c0 Mon Sep 17 00:00:00 2001 From: David Leach Date: Wed, 30 Sep 2015 10:07:21 +1300 Subject: Add support for disabling ssl verification for hex Uses global rebar config to see if user wishes to disable ssl verfication. If {ssl_verify, false} is present certificates will not be verified. --- src/rebar_pkg_resource.erl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl index f456587..4458c5b 100644 --- a/src/rebar_pkg_resource.erl +++ b/src/rebar_pkg_resource.erl @@ -129,6 +129,14 @@ etag(Path) -> end. ssl_opts(Url) -> + case get_ssl_config() of + ssl_verify_enabled -> + ssl_opts(ssl_verify_enabled, Url); + ssl_verify_disabled -> + [{verify, verify_none}] + end. + +ssl_opts(ssl_verify_enabled, Url) -> case check_ssl_version() of true -> {ok, {_, _, Hostname, _, _, _}} = http_uri:parse(ec_cnv:to_list(Url)), @@ -175,6 +183,16 @@ check_ssl_version() -> false end. +get_ssl_config() -> + GlobalConfigFile = rebar_dir:global_config(), + Config = rebar_config:consult_file(GlobalConfigFile), + case proplists:get_value(ssl_verify, Config, []) of + false -> + ssl_verify_disabled; + _ -> + ssl_verify_enabled + end. + parse_vsn(Vsn) -> version_pad(string:tokens(Vsn, ".")). -- cgit v1.1