Heim >Datenbank >MySQL-Tutorial >So richten Sie SSL für MySQL-Server und -Clients unter Linux ein
In diesem Tutorial werde ich vorstellen, wie man mithilfe der SSH-Verbindungsverschlüsselung eine sichere Verbindung zum MySQL-Server herstellt, sodass die Daten in der Datenbank sicher sind und Hacker die Daten nicht stehlen können. SSL wird zur Überprüfung von SSL-Zertifikaten verwendet, wodurch Phishing-Angriffe verhindert werden können. Hier erfahren Sie auch, wie Sie SSL auf Ihrem MySQL-Server aktivieren.
Stellen Sie eine Verbindung zum MySQL-Server her und überprüfen Sie den SSL-Status des MySQL-Servers Fügen Sie das Zertifikat hinzu.
# mysql -u root -p mysql> show variables like '%ssl%'; Output: +---------------+----------+ | Variable_name | Value | +---------------+----------+ | have_openssl | DISABLED | | have_ssl | DISABLED | | ssl_ca | | | ssl_capath | | | ssl_cert | | | ssl_cipher | | | ssl_key | | +---------------+----------+ 7 rows in set (0.00 sec) mysql> \q Bye. Schlüssel .pem client-req.pem wird vom Server auf den Client kopiert.
# mkdir /etc/certificates # cd /etc/certificates
# openssl genrsa 2048 > ca-key.pem Generating RSA private key, 2048 bit long modulus ...................................................................................+++ ..........+++ e is 65537 (0x10001) # openssl req -newkey rsa:2048 -days 1000 -nodes -keyout server-key.pem > server-req.pem Generating a 2048 bit RSA private key ..................+++ ..............................................................................................+++ writing new private key to 'server-key.pem' You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]: State or Province Name (full name) []: Locality Name (eg, city) [Default City]: Organization Name (eg, company) [Default Company Ltd]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []: Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: # openssl x509 -req -in server-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem Signature ok subject=/C=XX/L=Default City/O=Default Company Ltd Error opening CA Certificate ca-cert.pem 139991633303368:error:02001002:system library:fopen:No such file or directory:bss_file.c:398:fopen('ca-cert.pem','r') 139991633303368:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:400: unable to load certificate Generating client certificatesFügen Sie später Einstellungen in der Datei /etc/my.cnf hinzu, sodass wir bei einer dauerhaften Verbindung zum MySQL-Server eine Verbindung über SSL herstellen sollten.
# openssl req -newkey rsa:2048 -days 1000 -nodes -keyout client-key.pem > client-req.pem Generating a 2048 bit RSA private key ...............................................+++ .................+++ writing new private key to 'client-key.pem' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]: State or Province Name (full name) []: Locality Name (eg, city) [Default City]: Organization Name (eg, company) [Default Company Ltd]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []: Email Address []: Please enter the following 'extra' attributes openssl x509 -req -in client-req.pem -days 1000 -CA ca-# cert.pem -CAkey ca-key.pem -set_serial 01 > client-cert.pem Signature ok subject=/C=XX/L=Default City/O=Default Company Ltd Error opening CA Certificate ca-cert.pem 140327140685640:error:02001002:system library:fopen:No such file or directory:bss_file.c:398:fopen('ca-cert.pem','r') 140327140685640:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:400: unable to load certificate to be sent with your certificate request A challenge password []: An optional company name []:
Das obige ist der detaillierte Inhalt vonSo richten Sie SSL für MySQL-Server und -Clients unter Linux ein. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!