2) SSL Connections (Allow SSL connections only)
3) Create Client Certificate (3 File - Client, Key, Server) pem
4) This 3 Files can put in MYSQL workbrench
5) Infra create pfx, this file will put in VS code and password.
6) Appsetting.json
"Connectionstrings": {
"ConnectionApp":"Uid=[id];Pwd=[password];Server=[ip];port=3306;Database=[dbName]",
"SSLCertFile": "[mysql.pfx]",
"SSLCertPassword": "[sslPassword]"
},
7) Code
public MySqlConnection AppConnection()
{
var connectionString = new MySqlConnectionStringBuilder(ConnectionApp)
{
SslMode = MySqlSslMode.Required,
CertificateFile =
System.IO.Path.Combine(Directory.GetCurrentDirectory(), "SSL", SSLCertFile),
CertificatePassword = SSLCertPassword,
AllowUserVariables = true,
};
return new
MySqlConnection(connectionString.ConnectionString);
}
8)Every Method
using (MySqlConnection conn = CargoTrackConnection())
No comments:
Post a Comment