You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just spent a few hours trying to connect, using version 1.4.1 and OTP 26, to my DB hosted on Mongodb Atlas.
I finally found the problem and, even if the solution does exist in another issue it would have been much easier if there just was a code example of how to connect to a db hosted on Atlas (which I believe is something I won't be the only person to try to accomplish).
More precisely, the following snippet shows how to load the OS certificates and to make the hostname check work using the customize_hostname_check.
Something like this :
defmodule Atlas.Example do
def connect do
{:ok, conn} = Mongo.start_link(
url: "mongodb+srv://<user>:<password>@the-rest-of-the-url",
ssl: true,
ssl_opts: [
verify: :verify_peer,
cacerts: :public_key.cacerts_get(),
customize_hostname_check: [
match_fun:
:public_key.pkix_verify_hostname_match_fun(:https)
]
]
)
conn
end
end
Thank you!
The text was updated successfully, but these errors were encountered:
thanks for reporting. This is a fundamental issue for a TLS network connection regarding the Erlang's ssl module. The documentation can be found here: https://www.erlang.org/doc/apps/ssl/ssl.html
Hi,
I just spent a few hours trying to connect, using version 1.4.1 and OTP 26, to my DB hosted on Mongodb Atlas.
I finally found the problem and, even if the solution does exist in another issue it would have been much easier if there just was a code example of how to connect to a db hosted on Atlas (which I believe is something I won't be the only person to try to accomplish).
More precisely, the following snippet shows how to load the OS certificates and to make the hostname check work using the customize_hostname_check.
Something like this :
Thank you!
The text was updated successfully, but these errors were encountered: