In my config/prod*.exs I want to be able to use some type of abstract name for the ssl configuration file names, rather than actual filenames.
System.get_env does not help, because the config/prod*.exs files are run at release time. If env vars were going to be my solution, then it would need to read them at runtime.
E.g. instead of the usual config like so:
config :my_qap, MyQap.Endpoint,
url: [host: "somewhere.com"],
https: [port: 1234,
otp_app: :my_app,
keyfile: "priv/ssl/key.pem",
certfile: "priv/ssl/cer.pem",
cacertfile: "priv/ssl/certs.pem",
],
I’d like to be able to do something like this:
config :my_qap, MyQap.Endpoint,
url: [host: "somewhere.com"],
https: [port: {:system, "PORT"}, # this one works at least
otp_app: :my_app,
keyfile: {:system, "KEYFILE"}, # but there is no support in
certfile: {:system, "CERTFILE"}, # Plug.Adapters.Cowboy
cacertfile: {:system, "CACERTFILE"}, # for this, unfortunately
],
Possibly the change could be added into Plug.Adapters.Cowboy
at this point (plug/lib/plug/adapters/cowboy.ex at main · elixir-plug/plug · GitHub)
defp normalize_ssl_file(key, cowboy_options) do
value = cowboy_options[key]
cond do
is_nil(value) ->
cowboy_options
Path.type(value) == :absolute ->
put_ssl_file cowboy_options, key, value
true ->
put_ssl_file cowboy_options, key, Path.expand(value, otp_app(cowboy_options))
end
end
Any thoughts on this? Advice?


















