[pythian@idology08 ssl-keys]$ mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 39Server version: 5.0.45-log Source distributionType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> \s--------------mysql Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (x86_64) using readline 5.0Connection id: 39Current database:Current user: root@localhostSSL: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.0.45-log Source distributionProtocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: latin1Client characterset: latin1Conn. characterset: latin1UNIX socket: /var/lib/mysql/mysql.sockUptime: 31 min 26 secThreads: 2 Questions: 2565 Slow queries: 0 Opens: 25 Flush tables: 1 Open tables: 19 Queries per second avg: 1.360--------------mysql>
mysql>mysql>mysql>mysql> GRANT ALL PRIVILEGES ON *.* TO 'testSSL'@'localhost' IDENTIFIED BY 'test1234' REQUIRE X509;Query OK, 0 rows affected (0.01 sec)mysql> Aborted[pythian@idology08 ssl-keys]$ mysql -utestSSL -pEnter password:ERROR 1045 (28000): Access denied for user 'testSSL'@'localhost' (using password: YES)[pythian@idology08 ssl-keys]$ mysql -utestSSL -p --ssl-ca=ca-cert.pemEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 38Server version: 5.0.45-log Source distributionType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> \s--------------mysql Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (x86_64) using readline 5.0Connection id: 38Current database:Current user: testSSL@localhostSSL: Cipher in use is DHE-RSA-AES256-SHACurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.0.45-log Source distributionProtocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: latin1Client characterset: latin1Conn. characterset: latin1UNIX socket: /var/lib/mysql/mysql.sockUptime: 30 min 38 secThreads: 2 Questions: 2561 Slow queries: 0 Opens: 25 Flush tables: 1 Open tables: 19 Queries per second avg: 1.393--------------mysql>
mysql> GRANT ALL PRIVILEGES ON *.* TO 'testX509'@'localhost' IDENTIFIED BY 'test1234' REQUIRE X509;Query OK, 0 rows affected (0.00 sec)mysql> Aborted[pythian@idology08 ssl-keys]$ mysql -utestX509 -pEnter password:ERROR 1045 (28000): Access denied for user 'testX509'@'localhost' (using password: YES)[pythian@idology08 ssl-keys]$ mysql -utestX509 -p --ssl-ca=ca-cert.pemEnter password:ERROR 1045 (28000): Access denied for user 'testX509'@'localhost' (using password: YES)[pythian@idology08 ssl-keys]$ mysql -utestX509 -p --ssl-ca=ca-cert.pem --ssl-cert=idology08-client-cert.pem --ssl-key=idology08-client-key.pemEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 42Server version: 5.0.45-log Source distributionType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> \s--------------mysql Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (x86_64) using readline 5.0Connection id: 42Current database:Current user: testX509@localhostSSL: Cipher in use is DHE-RSA-AES256-SHACurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.0.45-log Source distributionProtocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: latin1Client characterset: latin1Conn. characterset: latin1UNIX socket: /var/lib/mysql/mysql.sockUptime: 35 min 47 secThreads: 2 Questions: 3059 Slow queries: 0 Opens: 25 Flush tables: 1 Open tables: 19 Queries per second avg: 1.425--------------mysql>
-bash-3.2$ ls -l /etc/pki/tls/certs/idology08.idologylive.com-ca-cert.pem-r--r----- 1 mysql mysql 1468 Nov 28 15:32 /etc/pki/tls/certs/idology08.idologylive.com-ca-cert.pem-bash-3.2$ ls -l /etc/pki/tls/certs/idology08.idologylive.com-ca-cert.pem-r--r----- 1 mysql mysql 1468 Nov 28 15:32 /etc/pki/tls/certs/idology08.idologylive.com-ca-cert.pem-bash-3.2$ ls -l /etc/pki/tls/private/idology08.idologylive.com.key-r--r----- 1 mysql mysql 1675 Nov 28 15:31 /etc/pki/tls/private/idology08.idologylive.com.key-bash-3.2$ exitlogout[pythian@idology08 etc]$ sudo /etc/init.d/mysqld stop081128 15:38:24 [Note] /usr/libexec/mysqld: Normal shutdown081128 15:38:25 InnoDB: Starting shutdown...Stopping MySQL: [ OK ][pythian@idology08 etc]$[pythian@idology08 etc]$ 081128 15:38:28 InnoDB: Shutdown completed; log sequence number 0 1114958497081128 15:38:28 [Note] /usr/libexec/mysqld: Shutdown complete081128 15:38:28 mysqld ended[pythian@idology08 etc]$ sudo /etc/init.d/mysqld start081128 15:38:37 mysqld startedStarting MySQL: [ OK ][pythian@idology08 etc]$ 081128 15:38:38 InnoDB: Started; log sequence number 0 1114958497081128 15:38:38 [Note] /usr/libexec/mysqld: ready for connections.Version: '5.0.45-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution[pythian@idology08 etc]$ mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.0.45-log Source distributionType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> SHOW VARIABLES LIKE 'have%_ssl';+---------------+-------+| Variable_name | Value |+---------------+-------+| have_openssl | YES || have_ssl | YES |+---------------+-------+2 rows in set (0.00 sec)mysql> SHOW VARIABLES LIKE '%ssl%';+---------------+----------------------------------------------------------+| Variable_name | Value |+---------------+----------------------------------------------------------+| have_openssl | YES || have_ssl | YES || ssl_ca | /etc/pki/tls/certs/idology08.idologylive.com-ca-cert.pem || ssl_capath | || ssl_cert | /etc/pki/tls/certs/idology08.idologylive.com.pem || ssl_cipher | || ssl_key | /etc/pki/tls/private/idology08.idologylive.com.key |+---------------+----------------------------------------------------------+7 rows in set (0.00 sec)mysql>
# the CA, will be shared among all Idologyopenssl genrsa 2048 > ca-key.pemopenssl req -new -x509 -nodes -days 1000 -key ca-key.pem > ca-cert.pem# server keyopenssl req -newkey rsa:2048 -days 1825 -nodes -keyout idology08-key.pem > idology08-req.pemopenssl rsa -in idology08-key.pem -out idology08-key.pemopenssl x509 -req -in idology08-req.pem -days 1825 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > idology08-cert.pem# client keysopenssl req -newkey rsa:2048 -days 1825 -nodes -keyout idology08-client-key.pem > idology08-client-req.pemopenssl rsa -in idology08-client-key.pem -out idology08-client-key.pemopenssl x509 -req -in idology08-client-req.pem -days 1825 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > idology08-client-cert.pem[pythian@idology08 ssl-keys]$ ls -ltotal 72-rw-rw-r-- 1 pythian pythian 1468 Nov 28 15:17 ca-cert.pem-rw-rw-r-- 1 pythian pythian 1675 Nov 28 15:16 ca-key.pem-rw-rw-r-- 1 pythian pythian 1168 Nov 28 15:21 idology08-cert.pem-rw-rw-r-- 1 pythian pythian 1180 Nov 28 15:25 idology08-client-cert.pem-rw-rw-r-- 1 pythian pythian 1675 Nov 28 15:25 idology08-client-key.pem-rw-rw-r-- 1 pythian pythian 997 Nov 28 15:24 idology08-client-req.pem-rw-rw-r-- 1 pythian pythian 1675 Nov 28 15:20 idology08-key.pem-rw-rw-r-- 1 pythian pythian 989 Nov 28 15:19 idology08-req.pemdrwxrwxr-x 2 pythian pythian 4096 Nov 28 15:14 old[pythian@idology08 ssl-keys]$
(9:21:12 AM) Singer Wang (TPG-AIM): hey(9:21:13 AM) Singer Wang (TPG-AIM): jason(9:21:16 AM) Singer Wang (TPG-AIM): aer you there?09:55(9:56:50 AM) Singer Wang (TPG-AIM): /home/pythian/working/ssl-keys(9:57:04 AM) Singer Wang (TPG-AIM): ssl-ca=/etc/pki/tls/certs/idology08_cacert.pemssl-cert=/etc/pki/tls/certs/idology08_cacert.pemssl-key=/etc/pki/tls/private/idology08_key.pem(9:57:37 AM) corleyjazz2000 is no longer away.(9:57:37 AM) corleyjazz2000 is no longer idle.(9:57:55 AM) Singer Wang (TPG-AIM): the keys are in the /home/pythian one(9:58:21 AM) corleyjazz2000: ok(9:58:58 AM) Singer Wang (TPG-AIM): and those are the 3 lines:(9:58:59 AM) Singer Wang (TPG-AIM): ssl-ca=/etc/pki/tls/certs/idology08_cacert.pemssl-cert=/etc/pki/tls/certs/idology08_cacert.pemssl-key=/etc/pki/tls/private/idology08_key.pem(9:59:16 AM) Singer Wang (TPG-AIM): also, can you make suer the mysql user can read those files?(9:59:18 AM) Singer Wang (TPG-AIM): thanks :)(9:59:29 AM) corleyjazz2000: I thought we were using a different cert for CA and MySQL(9:59:47 AM) Singer Wang (TPG-AIM): I'd have to talk to danil(9:59:49 AM) Singer Wang (TPG-AIM): one sec10:00(10:00:06 AM) corleyjazz2000: k
mysql> SHOW VARIABLES LIKE 'have%_ssl';+---------------+----------+| Variable_name | Value |+---------------+----------+| have_openssl | DISABLED || have_ssl | DISABLED |+---------------+----------+2 rows in set (0.00 sec)mysql>
ssl-ca=/etc/pki/tls/certs/idology08_cacert.pemssl-cert=/etc/pki/tls/certs/idology08_cacert.pemssl-key=/etc/pki/tls/private/idology08_key.pem
[pythian@idology08 ssl-keys]$ openssl genrsa -out idology08_key.pem 2048[pythian@idology08 ssl-keys]$ openssl req -new -x509 -key idology08_key.pem -out idology08_cacert.pem -days 1825[pythian@idology08 ssl-keys]$ openssl req -newkey rsa:2048 -md5 -days 1825 -nodes -keyout client-key.pem > client-req.pem[pythian@idology08 ssl-keys]$ openssl x509 -req -in client-req.pem -days 1825 -md5 -CA idology08_cacert.pem -CAkey idology08_key.pem -set_serial 01 > client-cert.pem
[pythian@idology08 ssl-keys]$ pwd/home/pythian/working/ssl-keys[pythian@idology08 ssl-keys]$ ls -lhtotal 40K-rw-rw-r-- 1 pythian pythian 1.1K Nov 28 09:26 client-cert.pem-rw-rw-r-- 1 pythian pythian 1.7K Nov 28 09:25 client-key.pem-rw-rw-r-- 1 pythian pythian 960 Nov 28 09:25 client-req.pem-rw-rw-r-- 1 pythian pythian 1.4K Nov 28 09:22 idology08_cacert.pem-rw-rw-r-- 1 pythian pythian 1.7K Nov 28 09:20 idology08_key.pem
openssl genrsa -out idology08_key.pem [key_size]
openssl req -new -x509 -key idology08_key.pem -out idology08_cacert.pem -days [days_to_expire]
openssl req -newkey rsa:[key_length] -md5 -days [days_to_expire] -nodes -keyout client-key.pem > client-req.pem
openssl x509 -req -in client-req.pem -days [days_to_expire] -md5 -CA idology08_cacert.pem -CAkey idology08_key.pem -set_serial 01 > client-cert.pem
ssl-ca=/path_to_server_keys/idology08_cacert.pemssl-cert=/path_to_server_keys/idology08_cacert.pemssl-key=/path_to_server_keys/idology08_key.pem
UPDATE mysql.user SET ssl_type='X509' WHERE user=user_name;FLUSH PRIVILEGES;
mysql -u user_name -p --ssl-ca=idology08_cacert.pem --ssl-cer=client-cert.pem --ssl-key=client-key.pem
UPDATE mysql.user SET ssl_type='' WHERE user=user_name;FLUSH PRIVILEGES;
mysql> SELECT user, host FROM mysql.user;+---------+-----------+| user | host |+---------+-----------+| webdb | % | | webdbro | % | | root | localhost | | webdb | localhost | | webdbro | localhost | +---------+-----------+5 rows in set (0.00 sec)
openssl req -newkey rsa:1024 -md5 -days 1000 -nodes -keyout client-key.pem > client-req.pem
openssl x509 -req -in client-req.pem -days 1000 -md5 -CA server_cert -CAkey server_key -set_serial 01 > client-cert.pem
daniel@daniel-desktop:~/client_keys$ mysql -u test2 -p --ssl-ca=/home/daniel/client_ca.pem --ssl-cer=target-cert.pem --ssl-key=target-key.pem Enter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 16Server version: 5.0.45-Debian_1ubuntu3.3-log Debian etch distributionType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> SHOW STATUS LIKE 'Ssl_cipher';+---------------+--------------------+| Variable_name | Value |+---------------+--------------------+| Ssl_cipher | DHE-RSA-AES256-SHA | +---------------+--------------------+1 row in set (0.01 sec)
daniel@daniel-desktop:~/client_keys$ mysql -u test2 -p --ssl-ca=/home/daniel/client_ca.pem --ssl-cer=client_key.pem_cert.pem --ssl-key=client_key.pemEnter password: ERROR 2026 (HY000): SSL connection error
ssl-ca=/home/daniel/mysql_cacert.pemssl-cert=/home/daniel/mysql_cacert.pemssl-key=/home/daniel/mysql_prkey.pem
daniel@daniel-desktop:/var/lib/mysql$ mysql -u test_user -p --ssl-ca=/home/daniel/client_ca.pemEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 10Server version: 5.0.45-Debian_1ubuntu3.3-log Debian etch distributionType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> SHOW STATUS LIKE 'Ssl_cipher';+---------------+--------------------+| Variable_name | Value |+---------------+--------------------+| Ssl_cipher | DHE-RSA-AES256-SHA | +---------------+--------------------+1 row in set (0.00 sec)mysql> exit
daniel@daniel-desktop:/var/lib/mysql$ mysql -u test_user -p --ssl-ca=/home/daniel/mysql_cacert.pem Enter password: ERROR 2026 (HY000): SSL connection error
Created a test certificate in idology07 .[pythian@idology07 newcerts]$ openssl genrsa 2048 > ca-key.pemGenerating RSA private key, 2048 bit long modulus..+++...........................................................................+++e is 65537 (0x10001)[pythian@idology07 newcerts]$ openssl req -new -x509 -nodes -days 1000 \> -key ca-key.pem > ca-cert.pemYou are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [GB]:.State or Province Name (full name) [Berkshire]:.Locality Name (eg, city) [Newbury]:.Organization Name (eg, company) [My Company Ltd]:.Organizational Unit Name (eg, section) []:.Common Name (eg, your name or your server's hostname) []:idology07Email Address []:.[pythian@idology07 newcerts]$ openssl req -newkey rsa:2048 -days 1000 \> -nodes -keyout server-key.pem > server-req.pemGenerating 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 incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [GB]:.State or Province Name (full name) [Berkshire]:.Locality Name (eg, city) [Newbury]:.Organization Name (eg, company) [My Company Ltd]:.Organizational Unit Name (eg, section) []:.Common Name (eg, your name or your server's hostname) []:idology07Email Address []:.Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:pythianAn optional company name []:pythian[pythian@idology07 newcerts]$ openssl x509 -req -in server-req.pem -days 1000 \> -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pemSignature oksubject=/CN=idology07Getting CA Private Key[pythian@idology07 newcerts]$ openssl req -newkey rsa:2048 -days 1000 \> -nodes -keyout client-key.pem > client-req.pemGenerating 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 incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [GB]:.State or Province Name (full name) [Berkshire]:.Locality Name (eg, city) [Newbury]:.Organization Name (eg, company) [My Company Ltd]:.Organizational Unit Name (eg, section) []:.Common Name (eg, your name or your server's hostname) []:.Email Address []:.error, no objects specified in config fileproblems making Certificate Request[pythian@idology07 newcerts]$ openssl req -newkey rsa:2048 -days 1000 -nodes -keyout client-key.pem > client-req.pemGenerating 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 incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [GB]:.State or Province Name (full name) [Berkshire]:.Locality Name (eg, city) [Newbury]:.Organization Name (eg, company) [My Company Ltd]:.Organizational Unit Name (eg, section) []:.Common Name (eg, your name or your server's hostname) []:clientEmail Address []:.Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:clientAn optional company name []:.[pythian@idology07 newcerts]$ ls -ltrhtotal 56K-rw-rw-r-- 1 pythian pythian 1.7K Aug 11 06:55 ca-key.pem-rw-rw-r-- 1 pythian pythian 1.2K Aug 11 06:57 ca-cert.pem-rw-rw-r-- 1 pythian pythian 956 Aug 11 06:58 server-req.pem-rw-rw-r-- 1 pythian pythian 1.7K Aug 11 06:58 server-key.pem-rw-rw-r-- 1 pythian pythian 964 Aug 11 06:59 server-cert.pem-rw-rw-r-- 1 pythian pythian 920 Aug 11 07:10 client-req.pem-rw-rw-r-- 1 pythian pythian 1.7K Aug 11 07:10 client-key.pem[pythian@idology07 newcerts]$
mysql> show global variables like '%ssl%';+---------------+----------+| 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>Gone through the http://dev.mysql.com/doc/refman/5.0/en/secure-using-ssl.html document for sometime to create sample keys and certificates.[pythian@idology08 santhinesh]$ openssl genrsa 2048 > test-key.pemGenerating RSA private key, 2048 bit long modulus...........................................................................+++..................................+++e is 65537 (0x10001)[pythian@idology08 santhinesh]$ openssl req -new -x509 -nodes -days 1000 \> -key test-key.pem > test-key.pemunable to load Private Key12990:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:644:Expecting: ANY PRIVATE KEY[pythian@idology08 santhinesh]$ openssl genrsa 2048 > test-key.pemGenerating RSA private key, 2048 bit long modulus.......................................................................................+++.............+++e is 65537 (0x10001)[pythian@idology08 santhinesh]$ openssl req -new -x509 -nodes -days 1000 -key test-key.pem > test-cert.pemYou are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [GB]:INState or Province Name (full name) [Berkshire]:Andra PradeshLocality Name (eg, city) [Newbury]:HyderabadOrganization Name (eg, company) [My Company Ltd]:PYTHIANOrganizational Unit Name (eg, section) []:indiaCommon Name (eg, your name or your server's hostname) []:pythianEmail Address []:pythian@pythian.com[pythian@idology08 santhinesh]$[pythian@idology08 santhinesh]$[pythian@idology08 santhinesh]$[pythian@idology08 santhinesh]$[pythian@idology08 santhinesh]$ ls -ltrhtotal 40Kdrwxrwxr-x 2 pythian pythian 4.0K May 16 00:44 migration-rw-rw-r-- 1 pythian pythian 1.6K May 16 03:04 tables.txt-rw-rw-r-- 1 pythian pythian 1.5K May 16 03:04 tables1.txt-rw-rw-r-- 1 pythian pythian 1.7K Jul 3 11:46 test-key.pem-rw-rw-r-- 1 pythian pythian 1.7K Jul 3 11:48 test-cert.pem