【问题标题】:How can disable SSL peer verification in http client (httpc) in erlang如何在erlang的http客户端(httpc)中禁用SSL对等验证
【发布时间】:2018-05-04 23:04:23
【问题描述】:

我通过 http 客户端发送了一个 restfull api 请求,但出现以下错误:

{error,{failed_connect,[{to_address,{"https://example.com",443}},
{inet,[inet],{tls_alert,"record overflow"}}]}}

我发现 SSL 对等验证造成了这个问题。如何禁用它?

我的代码:

test() ->
   inets:start(),
   ssl:start(),
   RequestBody = "",
   Request = {"https://example.com", [{"X-API-CODE",""}, {"Accept","application/json"}, {"access-token",""}], "application/json", RequestBody},
   {ok, {_, _, ResponseBody}} = httpc:request(post, Request, [], []),
   io:format("~st", [ResponseBody]).

【问题讨论】:

    标签: ssl https erlang ca


    【解决方案1】:

    虽然禁用验证不是一个好主意,但可以通过在选项中使用{ssl, [{verify, verify_none}]}。 例子: httpc:request(get, {"https://revoked.badssl.com/", []}, [{ssl, [{verify, verify_none}]}], []).

    【讨论】:

      猜你喜欢
      • 2021-06-04
      • 2022-01-20
      • 2016-01-30
      • 1970-01-01
      • 2014-10-06
      • 2012-07-25
      • 2012-09-10
      • 1970-01-01
      • 2016-02-04
      相关资源
      最近更新 更多