diff options
author | David Leach <dleach@wetafx.co.nz> | 2015-09-30 10:07:21 +1300 |
---|---|---|
committer | David Leach <dleach@wetafx.co.nz> | 2015-09-30 13:51:12 +1300 |
commit | d3e83b7a9e53fa03ffc6b274ec1cc570cc0e41c0 (patch) | |
tree | 1aff268bbe9dd7ec8f4d5ed0f0f6f23aa33c06bb /src | |
parent | 19fbaa0a610bb0cb470d2922f1adc30cbbe719eb (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_pkg_resource.erl | 18 |
1 files changed, 18 insertions, 0 deletions
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, ".")). |