Navigation: Additional Tips and Resources > Database Tips > MySQL > Encrypting Network Traffic with MySQL |
The following example shows a set of commands to create MySQL server and client certificate and key files. You will need to respond to several prompts by the openssl commands. For testing, you can press Enter to all prompts. For production use, you should provide nonempty responses.
* Win32 OpenSSL v0.9.8o Light, available at: http://www.slproweb.com/download/Win32OpenSSL_Light-0_9_8o.exe * Win64 OpenSSL v0.9.8o Light, available at: http://www.slproweb.com/download/Win64OpenSSL_Light-0_9_8o.exe
if a message occurs during setup indicating '...critical component is missing: Microsoft Visual C++ 2008 Redistributables', cancel the setup and download one of the following packages as well, again depending on your architecture (32-bit or 64-bit):
* Visual C++ 2008 Redistributables (x86), available at: http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF&displaylang=en * Visual C++ 2008 Redistributables (x64), available at: http://www.microsoft.com/downloads/details.aspx?familyid=bd2a6171-e2d6-4230-b809-9a8d7548c1b6&displaylang=en
After installing the additional package, restart the OpenSSL setup.
Microsoft Windows [Version ...] Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Windows\system32>cd \
C:\>openssl OpenSSL> exit <<< If you see the OpenSSL prompt, installation was successful.
C:\>
Depending on your version of Windows, the preceding instructions might be slightly different.
* Open a Windows Command prompt ('Start' -> 'Run' -> type 'CMD.EXE')
#Create clean environment C:\WINDOWS\System32\>md C:\newcerts C:\WINDOWS\System32\>cd C:\newcerts
# Create CA certificate C:\newcerts\>openssl genrsa 2048 > ca-key.pem C:\newcerts\>openssl req -new -x509 -nodes -days 1000 -key ca-key.pem > ca-cert.pem
# Create server certificate C:\newcerts\>openssl req -newkey rsa:2048 -days 1000 -nodes -keyout server-key.pem > server-req.pem C:\newcerts\>openssl x509 -req -in server-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem
# Create client certificate C:\newcerts\>openssl req -newkey rsa:2048 -days 1000 -nodes -keyout client-key.pem > client-req.pem C:\newcerts\>openssl x509 -req -in client-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > client-cert.pem
Testing SSL connections
[client] ssl-ca="C:/newcerts/ca-cert.pem" ssl-cert="C:/newcerts/client-cert.pem" ssl-key="C:/newcerts/client-key.pem"
[mysqld] ssl-ca="C:/newcerts/ca-cert.pem" ssl-cert="C:/newcerts/server-cert.pem" ssl-key="C:/newcerts/server-key.pem"
grant SELECT, INSERT on *.* to root@client_domain_or_IP_address IDENTIFIED BY "password" REQUIRE SSL; ("client_domain_or_IP_address" will be replaced with the IP address of the system you are attempting to attach from and "password" will be replaced with the password for that account)
|