postgresql 如果我的应用程序没有启用 SSL,为什么连接到 Azure 中的 Postgres 服务器会失败?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44031721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:34:24  来源:igfitidea点击:

Why does connection to my Postgres server in Azure fail if my app does not have SSL enabled?

postgresqlazureazure-database-postgresql

提问by Shantanu

I get a connection failure when I try to connect to my postgres server in Azure from my app/client, which does not have SSL enabled.

当我尝试从未启用 SSL 的应用程序/客户端连接到 Azure 中的 postgres 服务器时,连接失败。

Unable to connect to server: FATAL: SSL connection is required. Please specify SSL options and retry.

无法连接到服务器:致命:需要 SSL 连接。请指定 SSL 选项并重试。

Is this a strong requirement? Is there a way I can circumvent this requirement?

这是一个很强的要求吗?有没有办法绕过这个要求?

采纳答案by Shantanu

By default, Azure Database for PostgreSQL enforces SSL connections between your server and your client applications to protect against MITM (man in the middle) attacks. This is done to make the connection to your server as secure as possible.

默认情况下,Azure Database for PostgreSQL 强制在服务器和客户端应用程序之间建立 SSL 连接,以防止 MITM(中间人)攻击。这样做是为了使与您的服务器的连接尽可能安全。

Although not recommended, you have the option to disable requiring SSL for connecting to your server if your client application does not support SSL connectivity. Please check How to Configure SSL Connectivityfor your Postgres server in Azure for more details. You can disable requiring SSL connections from either the portal or using CLI. Note that Azure does not recommend disabling requiring SSL connections when connecting to your server.

虽然不推荐,但如果您的客户端应用程序不支持 SSL 连接,您可以选择禁用要求 SSL 连接到您的服务器。请查看如何为Azure 中的 Postgres 服务器配置 SSL 连接以了解更多详细信息。您可以从门户或使用 CLI 禁用要求 SSL 连接。请注意,Azure 不建议在连接到服务器时禁用要求 SSL 连接。

回答by Juli?n

Rather than bypassing this error and simply disabling SSL, you might also want to try simply enabling SSL by pimping up your connection string:

与其绕过此错误并简单地禁用 SSL,您可能还想尝试通过拉大连接字符串来简单地启用 SSL:

"Server=SERVERNAME.postgres.database.azure.com;
    Port=5432;Database=DBNAME;
    User Id=DBUSER@SERVERNAME;
    Password=PASSWORD;
    SslMode=Require";

Notice the SslMode=Requiresuffix at the end? This works with Npgsql as well (assuming you use C#) for connecting to an Azure Database for Postgresql.

注意到最后的SslMode=Require后缀了吗?这也适用于 Npgsql(假设您使用 C#)以连接到用于 Postgresql 的 Azure 数据库。

回答by Mikhail Sidorov

It helps me:

它帮助到我:

psql -v sslmode=true -h myapp.postgres.database.azure.com -U my_db_admin@myapp postgres

psql -v sslmode=true -h myapp.postgres.database.azure.com -U my_db_admin@myapp postgres