diff --git a/lib/tds/protocol.ex b/lib/tds/protocol.ex index f899704..e81b498 100644 --- a/lib/tds/protocol.ex +++ b/lib/tds/protocol.ex @@ -423,7 +423,23 @@ defmodule Tds.Protocol do end defp ssl_connect(%{sock: {:gen_tcp, sock}, opts: opts} = s) do - {:ok, _} = Application.ensure_all_started(:ssl) + {ssl_opts, opts} = + case Keyword.pop(opts, :ssl, false) do + {false, opts} -> + {nil, opts} + + {true, opts} -> + Logger.warning( + "setting ssl: true on your database connection offers only limited protection, " <> + "as the server's certificate is not verified. Set \"ssl: [cacertfile: \"/path/to/cacert.crt\"]\" instead" + ) + + # Read ssl_opts for backwards compatibility + Keyword.pop(opts, :ssl_opts, []) + + {ssl_opts, opts} when is_list(ssl_opts) -> + {Keyword.merge(default_ssl_opts(), ssl_opts), opts} + end case Tds.Tls.connect(sock, opts[:ssl_opts] || []) do {:ok, ssl_sock} ->