【问题标题】:ConnectionStrings in appsettings.json with ssl? Net Core带有ssl的appsettings.json中的ConnectionStrings?网络核心
【发布时间】:2022-01-12 17:47:56
【问题描述】:

如何将 api 连接到 azure mysql 数据库。

可能需要修改

"MySqlDbConnectionX": "Server = mydb.mysql.database.azure.com; Database = db; User Id = id; Password = password;"

为此

"MySqlDbConnectionX": Server = "mydb.mysql.database.azure.com"; UserID = "id"; Password = "{your_password}"; Database = "{your_database}"; SslMode = MySqlSslMode.Required; SslCa = "{path_to_CA_cert}"

我需要知道证书的路径,但我不知道把它放在哪里。

如果有人有例子,请发给我。

【问题讨论】:

  • 请解释不一样的原因,以便我解决问题。

标签: c# mysql azure asp.net-core web


【解决方案1】:

从您的描述中,我们可以清楚地知道您使用的是 Azure Database for Mysql。

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

Shantanu's answer,我们可以清楚地知道我们不需要在连接字符串中添加SslMode = MySqlSslMode.Required; SslCa = "{path_to_CA_cert}"

我还阅读了一些关于Client Certificate and Key for Azure Database for MySQL 的描述。

使用托管的 Azure MySQL 实例时,无法在 MySQL 服务器上存储 CA 证书。


所以如果要启用 ssl,可以直接从 azure 门户复制并使用连接字符串。

【讨论】:

    猜你喜欢
    • 2019-08-03
    • 1970-01-01
    • 2021-08-30
    • 1970-01-01
    • 2016-11-16
    • 1970-01-01
    • 1970-01-01
    • 2020-10-16
    • 1970-01-01
    相关资源
    最近更新 更多