2

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
  • Which version of Debian? On ArchLinux and on Debian "sid" (unstable), your program works so it is not a Linux issue, but may be the fact that on your Debian, you use a different version of Erlang/OTP, where some of the options were different. – bortzmeyer Feb 25 '23 at 08:27
  • I tried my Raspberry Pi 1B and a handful of AWS EC2 Linux operating systems. Is there a way to downgrade the Erlang version on MacOS to confirm this is the case? If it's a version support issue, are the Elixir devs looking to support other OSes? – Freddie Woodruff Feb 25 '23 at 15:15
  • *Is there a way to downgrade the Erlang version on MacOS to confirm this is the case?* -- You can use [asdf](https://asdf-vm.com) to install any erlang version you want and switch between versions at will. I use MacPorts rather than Homebrew to install dependencies. – 7stud Feb 26 '23 at 17:11
  • Question was solved by op in comments here: https://stackoverflow.com/questions/75554773/simple-ssl-server-client-connection-in-elixir – 7stud Feb 26 '23 at 17:17
  • @FreddieWoodruff As I said, this is not an OS issue. Debian version "sid" the most recent one) has no problem with your code. – bortzmeyer Feb 26 '23 at 18:02

0 Answers0