Uchoa
Hello everyone
I’m newcomer for here and mainly using elixir language. Currently I’m trying to connect my system (Elixir) with an Azure Database for PostgreSQL using ssl certificate. I downloaded the certificate from the blue documents page (f.e.: BaltimoreCyberTrustRoot.crt.pem), but every time I try to run the system it throws the following error:
12:50:29.007 [error] Postgrex.Protocol (pid<0.165.0>) failed to connect: ** (DBConnection.ConnectionError) ssl connect: closed
12:50:29.019 [error] Postgrex.Protocol (pid<0.164.0>) failed to connect: ** (DBConnection.ConnectionError) ssl connect: closed
12:50:30.981 [error] Postgrex.Protocol (pid<0.165.0>) failed to connect: ** (DBConnection.ConnectionError) ssl connect: closed
12:50:31.254 [error] Postgrex.Protocol (pid<0.164.0>) failed to connect: ** (DBConnection.ConnectionError) ssl connect: closed
12:50:31.445 [error] Could not create schema migrations table. This error usually happens due to the following:
- The database does not exist
- The “schema_migrations” table, which Ecto uses for managing
migrations, was defined by another library - There is a deadlock while migrating (such as using concurrent
indexes with a migration_lock)
To fix the first issue, run “mix ecto.create”.
To address the second, you can run “mix ecto.drop” followed by
“mix ecto.create”. Alternatively you may configure Ecto to use
another table and/or repository for managing migrations:
config :database, Database.Repo,
migration_source: "some_other_table_for_schema_migrations",
migration_repo: AnotherRepoForSchemaMigrations
The full error report is shown below.
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2983ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:
- Ensuring your database is available and that you can connect to it
- Tracking down slow queries and making sure they are running fast enough
- Increasing the pool_size (albeit it increases resource consumption)
- Allowing requests to wait longer by increasing :queue_target and :queue_interval
Can someone help me?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 10 of 14 Posts
ruslandoga
You can pass your certs in
:ssl_optswhen configuring the repo.Uchoa
I already passed. Here are the settings:
config :database, Database.Repo,
database: cgc_db_name,
username: cgc_db_username,
password: cgc_db_password,
hostname: cgc_db_hostname,
port: String.to_integer(cgc_db_port),
pool_size: String.to_integer(cgc_db_pool_size),
ssl: true,
ssl_opts: [
verify: :verify_peer,
versions: [:“tlsv1.2”],
ciphers: :ssl.cipher_suites(:all, :“tlsv1.2”),
cacertfile: cgc_db_cacertfile
]
ruslandoga
Here’s my working setup with google’s postgres:
Maybe it would help.
Uchoa
Ok, but you have 3 certificates: ca_cert, client_key and client_cert. In my case, I’m using Azure and the documentation only provides one certificate (BaltimoreCyberTrustRoot.crt.pem). I would like to know if the variable “verify” with the value “verify_peer” obligatorily asks for all certificates.
My attempts so far?
ruslandoga
You probably can’t do full verification (I guess that’s what
verify_peerstands for, but I’m not sure) with just a cacert, have you been able to connect to the db withpsql, it might have more info on what’s going wrong? Also try usingsslmode=requireandsslmode=verify-ca. I pass these in repo url:Uchoa
I haven’t tried that way yet
Uchoa
I’m trying again, but now the following error is appearing:
14:32:06.948 [error] Postgrex.Protocol (pid<0.2281.0>) failed to connect: ** (DBConnection.ConnectionError) ssl connect: TLS client: In state certify at ssl_handshake.erl:2017 generated CLIENT ALERT: Fatal - Handshake Failure
{bad_cert,hostname_check_failed} - {:tls_alert, {:handshake_failure, ‘TLS client: In state certify at ssl_handshake.erl:2017 generated CLIENT ALERT: Fatal - Handshake Failure\n {bad_cert,hostname_check_failed}’}}
ruslandoga
That’s much better as it at least shows the error now instead of plain
closed. Since the error reason ishostname_check_failedcan you please verify that the name in the certificate is the same as the one you are connecting to? Maybe the host name there is something likemy-db.azure.comand you are connecting to13.48.123.123or something like this.You can do it with
openssl: https://unix.stackexchange.com/questions/103461/get-common-name-cn-from-ssl-certificateKristerV
i am at this exact state now. any chance you have a working config you can share?
ruslandoga
I think Postgrex should be able to handle it automatically in the recent versions (v0.18.0 and up).
For an older Postgrex this seems to work:
The important bit that was missing from my previous replies is
server_name_indication.