MariaDB 10.3 : SSL/TLS の設定2020/01/23 |
MariaDB で SSL/TLS による暗号化通信の設定を有効にします。
|
|
[1] | |
[2] | 作成した証明書をコピーして SSL/TLS の設定をします。 |
# 取得した証明書をコピー [root@www ~]# cp /etc/letsencrypt/live/www.srv.world/* /etc/opt/rh/rh-mariadb103/pki/
[root@www ~]#
chown -R mysql. /etc/opt/rh/rh-mariadb103/pki/*
[root@www ~]#
vi /etc/opt/rh/rh-mariadb103/my.cnf.d/mariadb-server.cnf # [mysqld] セクション内に追記 [mysqld]
ssl-ca=/etc/opt/rh/rh-mariadb103/pki/chain.pem
ssl-cert=/etc/opt/rh/rh-mariadb103/pki/cert.pem ssl-key=/etc/opt/rh/rh-mariadb103/pki/privkey.pem
[root@www ~]#
systemctl restart rh-mariadb103-mariadb
# 設定確認 [root@www ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 10.3.13-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # 以下のように表示されればOK MariaDB [(none)]> show variables like '%ssl%'; +---------------------+-------------------------------------------+ | Variable_name | Value | +---------------------+-------------------------------------------+ | have_openssl | YES | | have_ssl | YES | | ssl_ca | /etc/opt/rh/rh-mariadb103/pki/chain.pem | | ssl_capath | | | ssl_cert | /etc/opt/rh/rh-mariadb103/pki/cert.pem | | ssl_cipher | | | ssl_crl | | | ssl_crlpath | | | ssl_key | /etc/opt/rh/rh-mariadb103/pki/privkey.pem | | version_ssl_library | OpenSSL 1.0.2k-fips 26 Jan 2017 | +---------------------+-------------------------------------------+ 10 rows in set (0.001 sec) |
[3] | SSL/TLS で接続する場合は [ssl] オプションを指定して接続します。 |
[root@www ~]# mysql -u root -p --ssl Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.3.13-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # 接続状況確認 MariaDB [(none)]> show status like 'ssl_cipher'; +---------------+---------------------------+ | Variable_name | Value | +---------------+---------------------------+ | Ssl_cipher | DHE-RSA-AES256-GCM-SHA384 | +---------------+---------------------------+ 1 row in set (0.001 sec) MariaDB [(none)]> exit Bye # 非暗号化通信の場合 [root@www ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.3.13-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # 値はブランク MariaDB [(none)]> show status like 'ssl_cipher'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Ssl_cipher | | +---------------+-------+ 1 row in set (0.01 sec) |
[4] | ユーザーに対して SSL/TLS アクセスを必須にする場合は、以下のように設定します。 |
[root@www ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.3.13-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # SSL/TLS 必須ユーザーを新規作成 MariaDB [(none)]> create user redhat identified by 'password' require ssl; Query OK, 0 rows affected (0.00 sec) # SSL/TLS 必須ユーザーは ssl_type が ANY MariaDB [(none)]> select user,host,ssl_type from mysql.user; +--------+-----------+----------+ | user | host | ssl_type | +--------+-----------+----------+ | root | localhost | | | root | 127.0.0.1 | | | root | ::1 | | | cent | % | | | redhat | % | ANY | +--------+-----------+----------+ 5 rows in set (0.000 sec) # 既存ユーザーを SSL/TLS 必須にする 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 | | | cent | % | ANY | | redhat | % | ANY | +--------+-----------+----------+ 5 rows in set (0.000 sec) |
Sponsored Link |