I’m running Ecto with mariaex, the database is on different server. And I’m using the ssl feature, here’s what I tried in prod.secret.exs
:
config :app, App.Repo,
adapter: Ecto.Adapters.MySQL,
ssl: true,
ssl_opts: [cacertfile: "ssl/ca.pem", certfile: "ssl/client-cert.pem", keyfile: "ssl/client-key.pem"]
Client keys sit in config/ssl
folder with prod.secret.exs
file.
When running migrate, I got these error:
Loading app..
Starting dependencies..
Starting repos..
Running migrations for app
02:49:40.250 [error] Mariaex.Protocol (#PID<0.96.0>) failed to connect: ** (Mariaex.Error) failed to upgraded socket: :enotconn
{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.DBConnection.ConnectionError',message=><<"connection not available because of disconnection">>},[{'Elixir.DBConnection',checkout,2,[{file,"lib/db_connection.ex"},{line,718}]},{'Elixir.DBConnection',run,3,[{file,"lib/db_connection.ex"},{line,619}]},{'Elixir.DBConnection',run_meter,3,[{file,"lib/db_connection.ex"},{line,921}]},{'Elixir.DBConnection',prepare_execute,4,[{file,"lib/db_connection.ex"},{line,463}]},{'Elixir.Ecto.Adapters.MySQL.Connection',execute,4,[{file,"lib/ecto/adapters/mysql/connection.ex"},{line,32}]},{'Elixir.Ecto.Adapters.SQL',sql_call,6,[{file,"lib/ecto/adapters/sql.ex"},{line,235}]},{'Elixir.Ecto.Adapters.SQL','query!',5,[{file,"lib/ecto/adapters/sql.ex"},{line,185}]},{'Elixir.Ecto.Adapters.MySQL',execute_ddl,3,[{file,"lib/ecto/adapters/mysql.ex"},{line,101}]}]}}
init terminating in do_boot ()
Crash dump is being written to: erl_crash.dump...done
Here’s what I found on mariaex github issue https://github.com/xerions/mariaex/issues/79 which is still open, but the change log https://github.com/xerions/mariaex/blob/master/CHANGELOG.md#078 seems to said it’s implemented.
I could connect to my database server running mysql in command line with the client keys. Not sure what could be wrong here, any suggest? Thanks very much.
Update
Here’s what I got when running release on my local computer:
23:21:13.460 [error] Mariaex.Protocol (#PID<0.1297.0>) failed to connect: ** (Mariaex.Error) failed to upgraded socket: {:options, {:ca
certfile, 'ssl/ca.pem', {:error, :enoent}}}