SSL errors logged during HTTPoison - how to suppress?

I’ve noticed a few weird log messages and I’ve tracked them down to HTTPoison, specifically do its ssl_verify_fun dependency. It comes up with certain flavors of bad SSL certs.

iex(1)> HTTPoison.get("")

00:44:35.072 [info]  TLS :client: In state :wait_cert_cr at ssl_handshake.erl:1933 generated CLIENT ALERT: Fatal - Certificate Expired

   id: nil,
   reason: {:tls_alert,
     'TLS client: In state wait_cert_cr at ssl_handshake.erl:1933 generated CLIENT ALERT: Fatal - Certificate Expired\n'}}

If I have :mfa enabled as one of the logger metadata fields, I see a blurb about the handshake.


My question is: is there a way to suppress the info message? It is redundant because HTTPoison returns the information as part of its error tuple. I’d like to handle the logging in a way that’s more appropriate for my app rather than having this message squeak out.

Thanks for any ideas.

You can set the ssl application’s log level using the :log_level option, for example log_level: :none.

However… if you were to just pass this option to HTTPoison like this…

HTTPoison.get("", [], ssl: [log_level: :none])

…you’ll find that the connection to this particular host suddenly succeeds, despite the expired certificate. This is because the ssl options overwrite Hackney’s server certificate verification options. The proper way to do this (with a recent Hackney version) would be:

ssl_opts =
  |> to_charlist()
  |> :hackney_ssl.check_hostname_opts()
  |> Keyword.put(:log_level, :none)
HTTPoison.get("", [], ssl: ssl_opts)

Thank you! This worked beautifully!