Search code examples
erlangelixir

Using a proxy and disabling SSL in Tesla using Hackney adapter


Here is what I'm doing after reading the docs. I want to use this on a per module basis so this is right in the module. This approach was based on this answer.

defmodule MyModule do
    use Tesla
    adapter Tesla.Adapter.Hackney, proxy: {"http://proxy.example.com", 5555}, ssl: {:verify, :verify_none}

However, I keep getting an :nxdomain error. The intended behaviour is for the HTTP requests to use the proxy and ignore any SSL certificate errors.


Solution

  • Figured it out. Here's how you set a proxy and disable SSL checks. I'm using Tesla with a Hackney adapter:

    defmodule MyModule do
      use Tesla
      adapter Tesla.Adapter.Hackney, proxy: "https://proxy.example.com:5000", ssl_options: [verify: :verify_none]
    

    If you'd like to specify the host and port separately, it will be:

    defmodule MyModule do
      use Tesla
      adapter Tesla.Adapter.Hackney, proxy: {"https://proxy.example.com", 5000}, ssl_options: [verify: :verify_none]