MySQL 8.0 : SSL/TLS सेटिंग2023/09/14 |
MySQL पर SSL/TLS सेटिंग कॉन्फ़िगर करें।
|
|
[1] | MySQL सर्वर साइड पर, mysqld डिफ़ॉल्ट रूप से स्व-हस्ताक्षरित प्रमाणपत्र उत्पन्न करता है, इसलिए डिफ़ॉल्ट रूप से SSL/TLS सत्र के साथ mysqld से कनेक्ट करना संभव है। |
# mysqld उन्हें उत्पन्न करता है root@dlp:~# ll /var/lib/mysql/*.pem -rw------- 1 mysql mysql 1705 Sep 28 01:36 /var/lib/mysql/ca-key.pem -rw-r--r-- 1 mysql mysql 1112 Sep 28 01:36 /var/lib/mysql/ca.pem -rw-r--r-- 1 mysql mysql 1112 Sep 28 01:36 /var/lib/mysql/client-cert.pem -rw------- 1 mysql mysql 1705 Sep 28 01:36 /var/lib/mysql/client-key.pem -rw------- 1 mysql mysql 1705 Sep 28 01:36 /var/lib/mysql/private_key.pem -rw-r--r-- 1 mysql mysql 452 Sep 28 01:36 /var/lib/mysql/public_key.pem -rw-r--r-- 1 mysql mysql 1112 Sep 28 01:36 /var/lib/mysql/server-cert.pem -rw------- 1 mysql mysql 1705 Sep 28 01:36 /var/lib/mysql/server-key.pemroot@dlp:~# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.30-0ubuntu0.22.04.1 (Ubuntu) Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # SSL सक्षम है mysql> show variables like '%ssl%'; +-------------------------------------+-----------------+ | Variable_name | Value | +-------------------------------------+-----------------+ | admin_ssl_ca | | | admin_ssl_capath | | | admin_ssl_cert | | | admin_ssl_cipher | | | admin_ssl_crl | | | admin_ssl_crlpath | | | admin_ssl_key | | | have_openssl | YES | | have_ssl | YES | | mysqlx_ssl_ca | | | mysqlx_ssl_capath | | | mysqlx_ssl_cert | | | mysqlx_ssl_cipher | | | mysqlx_ssl_crl | | | mysqlx_ssl_crlpath | | | mysqlx_ssl_key | | | performance_schema_show_processlist | OFF | | ssl_ca | ca.pem | | ssl_capath | | | ssl_cert | server-cert.pem | | ssl_cipher | | | ssl_crl | | | ssl_crlpath | | | ssl_fips_mode | OFF | | ssl_key | server-key.pem | | ssl_session_cache_mode | ON | | ssl_session_cache_timeout | 300 | +-------------------------------------+-----------------+ 27 rows in set (0.00 sec) # mysqld द्वारा जेनरेट किए गए प्रमाणपत्र 10 वर्षों के लिए उपलब्ध हैं mysql> show status like 'Ssl_server_not%'; +-----------------------+--------------------------+ | Variable_name | Value | +-----------------------+--------------------------+ | Ssl_server_not_after | Sep 25 01:36:30 2032 GMT | | Ssl_server_not_before | Sep 28 01:36:30 2022 GMT | +-----------------------+--------------------------+ 2 rows in set (0.00 sec) |
[2] | उपयोगकर्ताओं को SSL/TLS से जुड़ने के लिए बाध्य करने के लिए, निम्नानुसार सेट करें। |
root@dlp:~# mysql Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.30-0ubuntu0.22.04.1 (Ubuntu) Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # एक उपयोगकर्ता बनाएं जिसके लिए SSL/TLS आवश्यक हो mysql> create user debian identified by 'password' require ssl; Query OK, 0 rows affected (0.01 sec) # स्थिति दिखाएं SSL/TLS आवश्यक उपयोगकर्ता सेट [ssl_type] [ANY] mysql> select user,host,ssl_type,plugin from mysql.user; +------------------+-----------+----------+-----------------------+ | user | host | ssl_type | plugin | +------------------+-----------+----------+-----------------------+ | debian | % | ANY | caching_sha2_password | | ubuntu | % | | caching_sha2_password | | debian-sys-maint | localhost | | caching_sha2_password | | mysql.infoschema | localhost | | caching_sha2_password | | mysql.session | localhost | | caching_sha2_password | | mysql.sys | localhost | | caching_sha2_password | | root | localhost | | auth_socket | +------------------+-----------+----------+-----------------------+ 7 rows in set (0.00 sec) # किसी मौजूदा उपयोगकर्ता के लिए आवश्यक SSL/TLS सेट करें mysql> alter user 'ubuntu'@'%' require ssl; Query OK, 0 rows affected (0.01 sec) mysql> select user,host,ssl_type,plugin from mysql.user; +------------------+-----------+----------+-----------------------+ | user | host | ssl_type | plugin | +------------------+-----------+----------+-----------------------+ | debian | % | ANY | caching_sha2_password | | ubuntu | % | ANY | caching_sha2_password | | debian-sys-maint | localhost | | caching_sha2_password | | mysql.infoschema | localhost | | caching_sha2_password | | mysql.session | localhost | | caching_sha2_password | | mysql.sys | localhost | | caching_sha2_password | | root | localhost | | auth_socket | +------------------+-----------+----------+-----------------------+ 7 rows in set (0.00 sec) |
[3] | टीसीपी के माध्यम से कनेक्ट करने के लिए, SSL/TLS स्वचालित रूप से सक्षम है। |
root@dlp:~# mysql -u ubuntu -p --protocol=tcp Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 19 Server version: 8.0.30-0ubuntu0.22.04.1 (Ubuntu) Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # स्थिति दिखाओ mysql> show status like 'ssl_cipher'; +---------------+------------------------+ | Variable_name | Value | +---------------+------------------------+ | Ssl_cipher | TLS_AES_256_GCM_SHA384 | +---------------+------------------------+ 1 row in set (0.00 sec) mysql> exit Bye # बिना किसी SSL/TLS कनेक्शन पर root@dlp:~# mysql -u ubuntu -p --ssl-mode=disabled --protocol=tcp Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 44 Server version: 8.0.30-0ubuntu0.22.04.1 (Ubuntu) Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # मान खाली है mysql> show status like 'ssl_cipher'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Ssl_cipher | | +---------------+-------+ 1 row in set (0.00 sec) mysql> exit Bye |
Sponsored Link |
|