How do i connect api to azure mysql database.
Maybe need to change this
"MySqlDbConnectionX": "Server = mydb.mysql.database.azure.com; Database = db; User Id = id; Password = password;"
for this
"MySqlDbConnectionX": Server = "mydb.mysql.database.azure.com"; UserID = "id"; Password = "{your_password}"; Database = "{your_database}"; SslMode = MySqlSslMode.Required; SslCa = "{path_to_CA_cert}"
I would need to know the path to cert, but I don't know where to put it.
If anyone has an example, please send me.
CodePudding user response:
From your description, we can clearly know that you are using Azure DataBase for Mysql.
By default, Azure Database for MySQL 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.
From Shantanu's answer , we can clear know we don't need to add SslMode = MySqlSslMode.Required; SslCa = "{path_to_CA_cert}"
in our connectionstring.
And I also read some description about the Client Certificate and Key for Azure Database for MySQL.
This is not possible to store a CA certificate on the MySQL server when using the hosted Azure MySQL instance.
So if you want enable ssl, you can copy and use the connection string from azure portal directly.