DougReeder

DougReeder

Reverse_proxy_plug appears to not use :verify and :cacerts arguments

We’re using ReverseProxyPlug in a Phoenix server, and we have been configuring it like so:

opts =
  ReverseProxyPlug.init(
    upstream: url,
    allowed_origins: allowed_origins,
    proxy_url: "#{cors_scheme}://#{cors_host}:#{cors_port}",
    # We need to force the host
    # used for ssl verification here so that the connection isn't rejected.
    # Note that we have to convert the authority to a charlist, since this uses Erlang's `ssl` module
    # internally, which expects a charlist.
    client_options: [
      ssl: [
        {:server_name_indication, to_charlist(authority)},
        {:versions, [:"tlsv1.2", :"tlsv1.3"]}
      ]
    ]
  )

Thus, we’ve been getting the log message

~c"Server authenticity is not verified since certificate path validation is not enabled"
Reason: ~c"The option {verify, verify_peer} and one of the options ‘cacertfile’ or ‘cacerts’ are required to enable this."

So, I’ve updated to

opts =
  ReverseProxyPlug.init(
    upstream: url,
    allowed_origins: allowed_origins,
    proxy_url: "#{cors_scheme}://#{cors_host}:#{cors_port}",
    # We need to force the host
    # used for ssl verification here so that the connection isn't rejected.
    # Note that we have to convert the authority to a charlist, since this uses Erlang's `ssl` module
    # internally, which expects a charlist.
    client_options: [
      ssl: [
        {:server_name_indication, to_charlist(authority)},
        {:versions, [:"tlsv1.2", :"tlsv1.3"]},
        {:verify, :verify_peer},
        {:partial_chain, :auto},
        {:cacerts, :public_key.cacerts_get()}
      ]
    ]
  )

I’ve ensured that root certificates are installed on the system, and are used by openssl:

$ openssl s_client -connect www.archive.org:443

Verify return code: 0 (ok)

But now the proxy request fails, sending a status 502, and we’re still getting the log message

~c"Server authenticity is not verified since certificate path validation is not enabled"
Reason: ~c"The option {verify, verify_peer} and one of the options ‘cacertfile’ or ‘cacerts’ are required to enable this."

What should I look at to debug this?

Where Next?

Popular in Questions Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement