Encrypt data traffic between c# and mysql

2019-06-09 06:11发布

I have a windows application in C#.Net which uses mysql database to store data. Mysql DB and windows application are on the same machine. I am working through a security audit for a system at my work and one of the requirements is to encrypt all traffic between C# and Mysql. I have already implemented openssl and the connection has now encrypted but I also need to encrypt the Data traffic between c# and mysql. For e.g when the insert query executes from c#, the packet software (echo mirage) shows clear text(whole insert query with data) may be the reason is my c# application is using hardcode queries instead of stored procedures. How can I encrypt the traffic? Please help

1条回答
Animai°情兽
2楼-- · 2019-06-09 06:43

If one of your requirements is "to encrypt all traffic between C# and Mysql", then I would recommend setting the require_secure_transport system variable (on your MySQL Server) to 1. This will prevent any insecure connections from being created at all.

You will also need to configure your MySQL Server to use SSL, as per this tutorial (which you referenced in the comments).

In your C# program, make sure you have SslMode=Required in your connection string. This will ensure that all traffic between C# and MySQL, including queries and responses, is encrypted (apart from a short plaintext handshake at the very beginning of a connection).

Once this is done, Echo Mirage (or any network packet capture tool) will not be able to read the plain text of queries on the wire.

查看更多
登录 后发表回答