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.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
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23490154/viewspace-1062520/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- C#通過java生成的RSA公鑰加密和解密C#Java加密解密
- 通過實體類生成 mysql 的建表語句MySql
- [SSL]公鑰與私鑰典型應用
- SSH 公鑰私鑰的生成管理
- Git祕鑰問題Git
- openSSL生成公鑰和私鑰
- IBM Rational Software Architect 通過程式設計方式生成UML模型IBM程式設計模型
- SpringBoot介面 - 如何生成介面文件之非侵入方式(通過註釋生成)Smart-Doc?Spring Boot
- https祕鑰互動HTTP
- php使用openssl生成公鑰私鑰PHP
- 生成 Git 公鑰Git
- 通過Cache::Memcached::Fast方式AST
- Oracle通過Sqlplus結合Shell指令碼方式生成Excel檔案OracleSQL指令碼Excel
- 透過自定義域名 + SSL 的方式訪問 Amazon MQ for RabbitMQMQ
- 通過shell解析dump生成parfile
- 使用openssl生成rsa公鑰和私鑰
- ssl 生成證書
- Linux 配置祕鑰登入Linux
- Java生成公私鑰對Java
- TLS、SSL、CA 證書、公鑰、私鑰。。。今天捋一捋!TLS
- git生成ssh金鑰詳細步驟 git如何生成ssh金鑰Git
- Mac 使用openssl生成RSA公鑰和私鑰Mac
- 通過代理的方式讓Spring注入ServletSpringServlet
- 如何保護SSL證書私鑰安全
- nginx通過rewrite方式處理路由Nginx路由
- 怎麼通過Python掙外快,通過Python掙外快的幾種方式!Python
- mysql 通過IP連線MySql
- 生成公鑰連結githubGithub
- SSH-keygen rsa 金鑰對根據私鑰生成公鑰
- 通過註解的方式向DAO中注入SessionfactorySession
- git如何生成ssh金鑰 git生成配置ssh金鑰key詳細步驟Git
- 10 建立SSL與RSA證書與金鑰
- 通過類名動態生成物件物件
- 有關https的SSL加密方式HTTP加密
- Oracle 通過儲存過程來生成CSV檔案Oracle儲存過程
- 非對稱加密技術:共享祕鑰加密
- ssm框架整合redis(demo)---通過cache方式SSM框架Redis
- 把Java生成的RSA公鑰、私鑰轉換成.NET使用的XML格式JavaXML