mysql生成ssl作用_mysql通过ssl的方式生成秘钥具体生成步骤

mysql通过ssl的方式生成秘钥具体生成步骤

发布时间:2018-04-15 09:56:11

-- mysql ssl 生成秘钥

1 check ssl是否已经开启

mysql> show variables like '%ssl%';

+---------------+----------+

| Variable_name | Value |

+---------------+----------+

| have_openssl | DISABLED |

| have_ssl | DISABLED |

| ssl_ca | |

| ssl_capath | |

| ssl_cert | |

| ssl_cipher | |

| ssl_crl | |

| ssl_crlpath | |

| ssl_key | |

+---------------+----------+

9 rows in set (0.00 sec)

2 没有开启,所以打开

在my.cnf末尾端设置ssl 参数, 然后重新启动mysql服务即可

mysql> show variables like '%ssl%';

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| have_openssl | YES |

| have_ssl | YES |

| ssl_ca | |

| ssl_capath | |

| ssl_cert | |

| ssl_cipher | |

| ssl_crl | |

| ssl_crlpath | |

| ssl_key | |

+---------------+-------+

9 rows in set (0.00 sec)

3 通过openssl生成证书的配置, 在mysql db server上生成秘钥

mkdir -p /etc/mysql/newcerts/

cd /etc/mysql/newcerts/

3.1 openssl genrsa 2048 > ca-key.pem

3.2 openssl req -new -x509 -nodes -days 1000 -key ca-key.pem > ca-cert.pem

[root@mysql newcerts]# openssl req -new -x509 -nodes -days 1000 -key ca-key.pem > ca-cert.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]:ch

State or Province Name (full name) []:shh

Locality Name (eg, city) [Default City]:shh

Organization Name (eg, company) [Default Company Ltd]:xx

Organizational Unit Name (eg, section) []:db

Common Name (eg, your name or your server''s hostname) []:mysql.yest.nos

Email Address []:xx@xx.com

3.3 openssl req -newkey rsa:2048 -days 1000 -nodes -keyout server-key.pem > server-req.pem

[root@mysql newcerts]# 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]:ch

State or Province Name (full name) []:shh

Locality Name (eg, city) [Default City]:ssh

Organization Name (eg, company) [Default Company Ltd]:xx

Organizational Unit Name (eg, section) []:db

Common Name (eg, your name or your server''s hostname) []:mysql.yest.nos

Email Address []:xx@xx.com

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:820923

An optional company name []:xx

4 在mysql db server客户端生成ssl文件

4.1 openssl x509 -req -in server-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem

[root@mysql newcerts]# 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=ch/ST=shh/L=ssh/O=ea/OU=db/CN=mysql.yest.nos/emailAddress=cm@xx.com

Getting CA Private Key

4.2 openssl req -newkey rsa:2048 -days 1000 -nodes -keyout client-key.pem > client-req.pem

[root@mysql newcerts]# 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]:ch

State or Province Name (full name) []:shh

Locality Name (eg, city) [Default City]:shh

Organization Name (eg, company) [Default Company Ltd]:xx

Organizational Unit Name (eg, section) []:db

Common Name (eg, your name or your server''s hostname) []:mysql.yest.nos

Email Address []:cx@xx.com

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:820923

An optional company name []:xx

4.3

openssl x509 -req -in client-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > client-cert.pem

[root@mysql newcerts]# 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=ch/ST=shh/L=shh/O=ea/OU=db/CN=mysql.yest.nos/emailAddress=cm@xx.com

Getting CA Private Key

5

[]copy clent.* 3个文件到客户端机器上面/opt/mysql/ssl/去。

6 登陆验证

mysql -uxxx -pxxxx --ssl-ca=/opt/mysql/ssl/ca-cert.pem --ssl-cert=/opt/mysql/ssl/server-cert.pem --ssl-key=/opt/mysql/ssl/server-key.pem

conferce:http://www.docin.com/p-151590189.html

相关文章

在这篇博客的帖子里,我将会描述不同的使用MySQL数据库的SSL配置方法。

SSL给了你什么& 63;

你可以通过互联网使 2018-04-15

查看是否支持 SSL

首先在 MySQL 上执行如下命令, 查询是否 MySQL 支持 SSL:

mysql> SHOW VARIABLES 2018-04-15

1 进入mysql bin目录下输入mysqladmin processlist; 2 启动mysql,输入show processlist(关闭某一线程 k 2018-04-15

processlist命令的输出结果显示了有哪些线程在运行,可以帮助识别出有问题的查询语句,两种方式使用这个命令。1 2018-04-15

当mysql跨越互联网进行复制时别人可以窃取到mysql的复制信息,这些信息是明文的,因此存在不安全性,这里通过ssl 2018-04-15

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值