当前位置: 首页 > news >正文

mysql名称证书秘钥_mysql通过ssl的方式生成秘钥

-- 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.2openssl  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.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.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

相关文章:

  • ios操作mysql数据库_ios数据库操作
  • mybatis 调用mysql函数_mybatis mapper调用mysql存储过程
  • error msb6006: “cmd.exe”已退出 代码为1_Django安装与简单配置(1)
  • mysql 5.6.3 current_timestamp_mysql5.6以上版本: timestamp current_timestamp报1064/1067错误
  • mysql导入导致锁表_mysql 导出数据导致锁表
  • mysql order by 报错_mysql 高版本order by 报错解决方案
  • apache mysql windows_windows上apache+php+mysql环境部署
  • mysql5.6吞吐量_MySQL 5.5和MySQL 5.6的吞吐量测试
  • java中while循环_Java中do...while循环和for循环还有死循环
  • spark向MySQL刷新一个字段_Spark 实现MySQL update操作
  • vb将指针指向内容传数组_C语言指针
  • mysql json链接表_将JSON插入MySQL表中?
  • mysql 开发规范_mysql 开发标准规范
  • python colorbar xtick locator_python matplotlib colorbar设置tick formator / locator更改刻度标签...
  • python里data显示无效的语法_语法错误def Data(path)的语法无效
  • SegmentFault for Android 3.0 发布
  • [LeetCode] Wiggle Sort
  • 【刷算法】求1+2+3+...+n
  • 5、React组件事件详解
  • css系列之关于字体的事
  • Cumulo 的 ClojureScript 模块已经成型
  • java多线程
  • SOFAMosn配置模型
  • vue数据传递--我有特殊的实现技巧
  • 得到一个数组中任意X个元素的所有组合 即C(n,m)
  • 基于阿里云移动推送的移动应用推送模式最佳实践
  • 计算机在识别图像时“看到”了什么?
  • 看完九篇字体系列的文章,你还觉得我是在说字体?
  • 批量截取pdf文件
  • 深度学习入门:10门免费线上课程推荐
  • 算法系列——算法入门之递归分而治之思想的实现
  • 用jQuery怎么做到前后端分离
  • 这几个编码小技巧将令你 PHP 代码更加简洁
  • 交换综合实验一
  • #FPGA(基础知识)
  • #pragma data_seg 共享数据区(转)
  • %3cscript放入php,跟bWAPP学WEB安全(PHP代码)--XSS跨站脚本攻击
  • (1)(1.19) TeraRanger One/EVO测距仪
  • (1)Map集合 (2)异常机制 (3)File类 (4)I/O流
  • (20)目标检测算法之YOLOv5计算预选框、详解anchor计算
  • (4) openssl rsa/pkey(查看私钥、从私钥中提取公钥、查看公钥)
  • (C#)Windows Shell 外壳编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令...
  • (javascript)再说document.body.scrollTop的使用问题
  • (pojstep1.1.1)poj 1298(直叙式模拟)
  • (二)构建dubbo分布式平台-平台功能导图
  • (六)什么是Vite——热更新时vite、webpack做了什么
  • (四)c52学习之旅-流水LED灯
  • .NET 5.0正式发布,有什么功能特性(翻译)
  • .NET Core中Emit的使用
  • .NET/C# 使用 SpanT 为字符串处理提升性能
  • .NET关于 跳过SSL中遇到的问题
  • .net开发引用程序集提示没有强名称的解决办法
  • .net连接oracle数据库
  • @font-face 用字体画图标
  • [100天算法】-不同路径 III(day 73)