I appreciate this question appears highly similar to another I asked recently. However, while the solution there works on MacOS, on Debian I am getting different errors, and a different set of problems.
After a fresh install with sudo apt-get install elixir
(on an AWS EC2 instance), first I create a new project with mix new tls_question
. I have modified mix.exs like so:
def application do
[
extra_applications: [:logger, :crypto, :ssl]
]
end
I have then generated an SSL key and certificate in the project folder with
openssl req -nodes -new -x509 -keyout key.pem -out cert.pem
I then have the following minimal program
defmodule TlsQuestion do
def main do
:ssl.start()
{:ok, listen_socket} = :ssl.listen(8000,
[ certs_keys: [%{
:keyfile => "key.pem",
:certfile => "cert.pem",
}],
reuseaddr: true,
])
end
end
TlsQuestion.main()
Calling mix run
, I get the error:
== Compilation error in file lib/tls_question.ex ==
** (exit) :badarg
(kernel) inet_tcp.erl:142: :inet_tcp.listen/2
(ssl) tls_socket.erl:51: :tls_socket.listen/3
(ssl) ssl.erl:145: :ssl.listen/2
lib/tls_question.ex:4: TlsQuestion.main/0