MariaDB 10.2 : SSL/TLS Setting2017/10/30 |
Enable SSL/TLS connection to MariaDB.
|
|
[1] | |
[2] | Copy certificates created above and configure MariaDB. |
[root@www ~]# cp /etc/pki/tls/certs/server.key \ /etc/pki/tls/certs/server.crt \ /etc/pki/tls/certs/ca-bundle.crt \ /etc/opt/rh/rh-mariadb102/pki/ [root@www ~]# chown mysql. /etc/opt/rh/rh-mariadb102/pki/*
[root@www ~]#
vi /etc/opt/rh/rh-mariadb102/my.cnf.d/mariadb-server.cnf # add into [mysqld] section [mysqld]
ssl-ca=/etc/opt/rh/rh-mariadb102/pki/ca-bundle.crt
ssl-cert=/etc/opt/rh/rh-mariadb102/pki/server.crt ssl-key=/etc/opt/rh/rh-mariadb102/pki/server.key
[root@www ~]#
systemctl restart rh-mariadb102-mariadb
# verify [root@www ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.2.8-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # OK if status is like follows MariaDB [(none)]> show variables like '%ssl%'; +---------------------+---------------------------------------------+ | Variable_name | Value | +---------------------+---------------------------------------------+ | have_openssl | YES | | have_ssl | YES | | ssl_ca | /etc/opt/rh/rh-mariadb102/pki/ca-bundle.crt | | ssl_capath | | | ssl_cert | /etc/opt/rh/rh-mariadb102/pki/server.crt | | ssl_cipher | | | ssl_crl | | | ssl_crlpath | | | ssl_key | /etc/opt/rh/rh-mariadb102/pki/server.key | | version_ssl_library | OpenSSL 1.0.2k-fips 26 Jan 2017 | +---------------------+---------------------------------------------+ 10 rows in set (0.01 sec) |
[3] | To connect with SSL/TLS from Clients, connect with specifying [--ssl] option. |
[root@www ~]# mysql -u root -p --ssl Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.2.8-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # show status MariaDB [(none)]> show status like 'ssl_cipher'; +---------------+---------------------------+ | Variable_name | Value | +---------------+---------------------------+ | Ssl_cipher | DHE-RSA-AES256-GCM-SHA384 | +---------------+---------------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> exit Bye # for no SSL/TLS connection [root@www ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.2.8-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # value is empty MariaDB [(none)]> show status like 'ssl_cipher'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Ssl_cipher | | +---------------+-------+ 1 row in set (0.01 sec) |
[4] | To force require users to connect with SSL/TLS, set like follows. |
[root@www ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 15 Server version: 10.2.8-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # create a user who is required SSL/TLS MariaDB [(none)]> create user redhat identified by 'password' require ssl; Query OK, 0 rows affected (0.00 sec) # show status MariaDB [(none)]> select user,host,ssl_type from mysql.user; +--------+-----------+----------+ | user | host | ssl_type | +--------+-----------+----------+ | root | localhost | | | root | 127.0.0.1 | | | root | ::1 | | | redhat | % | ANY | | cent | % | | +--------+-----------+----------+ 5 rows in set (0.00 sec) # set SSL/TLS required to an existing user MariaDB [(none)]> grant usage on *.* to 'cent'@'%' require ssl; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> select user,host,ssl_type from mysql.user; +--------+-----------+----------+ | user | host | ssl_type | +--------+-----------+----------+ | root | localhost | | | root | 127.0.0.1 | | | root | ::1 | | | redhat | % | ANY | | cent | % | ANY | +--------+-----------+----------+ 5 rows in set (0.00 sec) |
Sponsored Link |
|