gpt4 book ai didi

ssl - 如何向 HTTPoison/hackney 添加可信证书?

转载 作者:太空宇宙 更新时间:2023-11-03 12:43:35 24 4
gpt4 key购买 nike

当我尝试时:

HTTPoison.get! "https://facebook.com"

我得到:

** (HTTPoison.Error) {:tls_alert, 'unknown ca'}
[error] SSL: :certify: ssl_handshake.erl:1606:Fatal error: unknown ca

(httpoison) lib/httpoison.ex:66: HTTPoison.request!/5

这是意料之中的,因为在我的公司,我需要信任防火墙的证书才能出去。

我在系统范围内信任证书(.cer 文件),这就是为什么 wget 在访问 https URL 时没有给我 ssl 错误。但是 hackney/HTTPPoison 似乎忽略了这个配置。

如何让 HTTPoison/hackney 将证书识别为可信证书?

最佳答案

证书文件路径被传递给 HTTPPoison 选项,如下所示:

   defp add_certs do
[
hackney: [ # :hackney options
ssl_options: [ # :ssl options
cacertfile: # CA certificate used to validate server cert; path(), "string" is ok
certfile: # client certificate, signed by CA; path(), "string" is ok
keyfile: # private key for client.crt; path(). "string" is ok
password: # password for keyfile; string(), "string" not ok, use 'char list'
]
]
]
end
HTTPoison.post(url, request_xml, headers, add_certs)

关于ssl - 如何向 HTTPoison/hackney 添加可信证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39919071/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com