MySQL connection using SSL… or not ?

MySQL connection using SSLIn this blog post, we’ll determine a MySQL connection using SSL… or not.

Since MySQL 5.7.5 the server generates SSL certificates (see auto_generate_certs) by default if compiled with SSL, or uses mysql_ssl_rsa_setup if compiled with YaSSL.

But how can we check to see if our MySQL client connection uses SSL?

When using an interactive client, it’s easy! You have two options:

1. Check the status(s):

As you can see, for that connection, we are indeed using SSL: SSL: Cipher in use is DHE-RSA-AES256-SHA

2. Use the status variables Ssl_version  and Ssl_cipher:

But is there a way to verify this on all the connections? For example, if we have some applications connected to our database server, how do we verify which connections are using SSL and which are not?

Yes, there is a solution: Performance_Schema!

This is how:

That’s it. Isn’t that easy? 😉

Share this post

Comments (6)

  • Mark Leith Reply February 24, 2016 at 1:54 am
    • Frederic Descamps Reply

      Hi Mark,

      Thank you for your quick reply, indeed sys schema is very useful, hopefully it’s now included by default 😉

      Thank you again to have pointed it here.

      February 24, 2016 at 2:06 am
      • Mark Leith Reply

        Yep, there by default since 5.7.7..

        February 24, 2016 at 2:16 am
  • Fadi El-Eter (itoctopus) Reply

    Hi Frederic,

    That “s” in the MySQL command line doesn’t work on any of the servers that we have tried. What could be the problem? Can you confirm it is really “s”?

    February 26, 2016 at 12:04 pm
  • Jeff Rule Reply

    I am on RDS using my ‘system’ account mysql version 5.7.19. When I try your query or the sys.session_ssl_status I get an empty list. I also come up empty with the base tables, they show no rows.

    my grants look like this from the show grants statement:
    Grants for my-user@%: GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO ‘my-user’@’%’ WITH GRANT OPTION

    my 56 compatibility variable looks like this. | show_compatibility_56 | OFF |

    Suggestions on how to get this to work or why it is not working?

    June 17, 2020 at 3:31 pm

Leave a Reply