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

2022-11-12 09:30:43
内容摘要
这篇文章主要为大家详细介绍了MySQL通过ssl的方式生成秘钥具体生成步骤,具有一定的参考价值,可以用来参考一下。 对此感兴趣的朋友,看看idc笔记做的技术笔记!-- mysql ssl 生成
文章正文

这篇文章主要为大家详细介绍了MySQL通过ssl的方式生成秘钥具体生成步骤,具有一定的参考价值,可以用来参考一下。

对此感兴趣的朋友,看看idc笔记做的技术笔记!

-- 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.pem3.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.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) [XX]:chState or Province Name (full name) []:shhLocality Name (eg, city) [Default City]:shhOrganization Name (eg, company) [Default Company Ltd]:xxOrganizational Unit Name (eg, section) []:dbCommon Name (eg, your name or your server''s hostname) []:mysql.yest.nosEmail Address []:xx@xx.com3.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.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) [XX]:chState or Province Name (full name) []:shhLocality Name (eg, city) [Default City]:sshOrganization Name (eg, company) [Default Company Ltd]:xxOrganizational Unit Name (eg, section) []:dbCommon Name (eg, your name or your server''s hostname) []:mysql.yest.nosEmail Address []:xx@xx.comPlease enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:820923An optional company name []:xx4 在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.pemSignature oksubject=/C=ch/ST=shh/L=ssh/O=ea/OU=db/CN=mysql.yest.nos/emailAddress=cm@xx.comGetting CA Private Key4.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.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) [XX]:chState or Province Name (full name) []:shhLocality Name (eg, city) [Default City]:shhOrganization Name (eg, company) [Default Company Ltd]:xxOrganizational Unit Name (eg, section) []:dbCommon Name (eg, your name or your server''s hostname) []:mysql.yest.nosEmail Address []:cx@xx.comPlease enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:820923An optional company name []:xx4.3openssl 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.pemSignature oksubject=/C=ch/ST=shh/L=shh/O=ea/OU=db/CN=mysql.yest.nos/emailAddress=cm@xx.comGetting CA Private Key5[]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.pemconferce:http://www.docin.com/p-151590189.html

注:关于MySQL通过ssl的方式生成秘钥具体生成步骤的内容就先介绍到这里,更多相关文章的可以留意

代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!