fwoodruff
I appreciate this question is highly similar to another I asked yesterday. However, while the solution there works on MacOS, on Debian I am getting different errors, and a different set of problems.
First I create a new project with mix new tls_question. I have added :crypto and :ssl to mix.exs like so:
def application do
[
extra_applications: [:logger, :crypto, :ssl]
]
end
I have then generated an SSL certificate with
openssl req -nodes -new -x509 -keyout key.pem -out cert.pem
and moved key.pem and cert.pem into the project folder.
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
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
New episode with Louis Pilfold - the most detailed conversation about Gleam’s design I’ve come across.
Worth knowing for the Elixir comm...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
al2o3cr
The
badarghere is caused bydo_connectnot finding an address to bind to (the bigwhenclause):https://github.com/erlang/otp/blob/401968245bbd92673512565f8f56305d78e62420/lib/kernel/src/inet_tcp.erl#L118-L144
Based on the
Compilation errorin the message, I believe the issue is theTlsQuestion.main()on the last line - that tries to start the listener when the file is compiled. That’s not needed if you’re launching it withmix run 'TlsQuestion.main()'.fwoodruff
I tried running
mix run 'TlsQuestion.main()'without changing the code. That gives the same error.I then tried removing the line
which gave the error:
I then tried making a similar project.
which gives the error
al2o3cr
Oops, that was a typo - there’s a flag missing. Should be
mix run -e 'TlsQuestion.main()'fwoodruff
That gives me
which seems to the same error with a slightly longer stack trace?
jjcarstens
I don’t believe
reuseaddris a valid listen option (according to gen_tcp — OTP 29.0.2 (kernel 11.0.2))Erlang SSL options can be confusing because they are all effectively included in the specs, but run through a very specific validation when attempting to run
fwoodruff
I’ve taken a look and I’m pretty sure the option is in there. Here is what it’s for.
I have attempted to remove the option anyway to see if anything different happens and the answer is no.
jjcarstens
You’re right. After a closer look, that option should be fine.
I tried the initial code you posted and it worked for me with
mix run -e 'TlsQuestion.main(). I might suggest hardcoding full paths to the cert/key and testing again. Also, what OTP version are you using?:certs_keysis a newer option in OTP 25. I tried this same code with OTP 24 and got the same error you see which makes me believe that thebadargis referencing thecerts_keysoption and your lower OTP version.You could instead just use this as well:
fwoodruff
I’m running OTP 21 on my Raspberry Pi. Is there an alternative way to get SSL working on OTP 21? I’ve rolled my own TLS 1.2 implementation before but that was in another language and I don’t fancy doing it again.
asdf install erlang latestgives me:then CCL seems to peg the CPU to 95% for hours. Attempts to install Java tell me ARMv6 isn’t good enough. It all suggests to me I’m stuck with OTP 21.
jjcarstens
Well, you have a few options:
Do you need multiple certs with
:certs_keys?certfileandkeyfileoption directly which should work with OTP 21If yes, do you need Java? That can be disabled. You would also need to install openSSL on the rpi and specify both of these in
KERL_CONFIGURE_OPTIONS.KERL_CONFIGURE_OPTIONS="--without-javac --with-ssl=/path/to/openssl/install"Are you using the whole raspberry pi OS? Or just to run Erlang/Elixir on it?
fwoodruff
This solves it thank you!!! Cool I’ll try that for installing Java. It might come in handy at some point.
I am currently using the whole Raspberry Pi OS. I can see you work at Nerves and I’ll take a look at it and spread the word!