【发布时间】:2021-12-18 08:55:01
【问题描述】:
我正在尝试在 tls_certificate_check 库、Elixir 和对 Erlang :ssl 模块的一些调用的帮助下验证我的网站 SSL 证书。最终目标是获取证书的到期日期,可能还有其他一些元数据。这是我的代码:
defmodule ElixirSslCheck do
def check do
host = "www.lawlorbagcal.org"
options = :tls_certificate_check.options(host)
:ssl.connect(host, 443, options, 5000)
end
end
在iex 中运行此程序后,我看到了以下输出:
iex(4)> ElixirSslCheck.check
{:error,
{:options,
{:socket_options,
[packet_size: 0, packet: 0, header: 0, active: false, mode: :binary]}}}
我不明白这是什么意思。阅读有关:ssl.connect 函数的文档,我看到规范说我应该在error 元组中接收reason:
connect(Host, Port, TLSOptions, Timeout) ->
{ok, sslsocket()} |
{ok, sslsocket(), Ext :: protocol_extensions()} |
{error, reason()} |
{option_not_a_key_value_tuple, any()}
我得到的回报似乎不是一个原因。我正在使用 tls_certificate_check 库,因为我认为它提供的 TLS 选项将帮助我解决与我的 SSL 证书相关的任何奇怪问题。也就是说,它是通配符让我们加密证书。
谁能帮助我进一步调试并让我朝着正确的方向前进?一旦我解决了连接问题,我想下一步是打电话给:ssl.peer_cert,我假设这会导致我到证书到期日期等。
【问题讨论】:
-
请检查
options是否包含:cacerts 和:cacertfile? -
嗨@AliShirvani。 :cacerts 存在,但 :cacertfile 为 :nil。