Frage

I have a client application written in VB.NET which connecting to a remote MySQL server. I'd like to sign on the UI when the connection is secure or insecure.

SslMode is set to Preferred (use SSL if the server supports it, but allow connection in all cases)

Once mysql connection established, how can I decide is it a secured connection or not?

Here is how my connection string looks like:

'Declaring the MySqlConnection
_MysqlConn = New MySqlConnection( _
               New MySqlConnectionStringBuilder() _
               With { _
                 .Port = port, _
                 .Server = server, _ 
                 .UserID = username, _ 
                 .Password = password, _ 
                 .Database = database, _
                 .SslMode = MySqlSslMode.Preferred _
               }.ConnectionString
             )

I'm using mysql.data (6.5.4.0) if it is matters.

Thank you for your help in advance!

War es hilfreich?

Lösung

http://dev.mysql.com/doc/refman/5.6/en/using-ssl-connections.html

A client can determine whether the current connection with the server uses SSL by checking the value of the Ssl_cipher status variable. The value of Ssl_cipher is nonempty if SSL is used, and empty otherwise. For example:

mysql> SHOW STATUS LIKE 'Ssl_cipher';
+---------------+--------------------+
| Variable_name | Value              |
+---------------+--------------------+
| Ssl_cipher    | DHE-RSA-AES256-SHA |
+---------------+--------------------+

Issue this command just like any regular query, and parse its result like a regular result set.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top