Phoenix release with SSL not connecting

This likely means the certificate and/or key files in the release can’t be read, so the TLS handshake gets aborted. Try starting the release with my_app start_iex, then check if the files specified in the configuration can be read and contain the expected certificate/key in PEM format:

iex(1)> https = Application.get_env(:my_app, MyAppWeb.Endpoint)[:https]
[
  port: 4001,
  otp_app: :my_app,
  cipher_suite: :strong,
  certfile: "priv/cert/selfsigned.pem",
  keyfile: "priv/cert/selfsigned_key.pem"
]
iex(2)> File.read(https[:certfile])
{:ok, ...}
iex(3)> File.read(https[:keyfile])
{:ok, ...}

If the file contents look ok, try adding transport_options: [socket_opts: [log_level: :info]] to your Endpoint’s https configuration, and see if :ssl logs any alerts.

BTW, I would recommend using a CLI tool such as curl -v -k https://... or openssl s_client -connect localhost:4001 ... rather than a browser to debug such issues, as they tend to produce much more helpful output, instead of PR_END_OF_FILE_ERROR.

2 Likes