简体   繁体   English

Ubuntu 14.04上的MySQL 5.5和SSL

[英]MySQL 5.5 and SSL on Ubuntu 14.04

I'm trying to set up a mysql server 5.5.38-0ubuntu0.14.04.1 with SSL support on an Ubuntu 14.04 Linux (64bit) with kernel 3.13.0-32-generic. 我正在尝试在具有内核3.13.0-32-generic的Ubuntu 14.04 Linux(64位)上设置具有SSL支持的mysql服务器5.5.38-0ubuntu0.14.04.1。

I allowed remote access to mysql and changed the /etc/mysql/my.cnf in order to support ssl... 我允许远程访问mysql并更改了/etc/mysql/my.cnf以支持ssl ...

ssl=1
ssl-ca=/etc/mysql/ca-cert.pem
ssl-cert=/etc/mysql/server-cert.pem
ssl-key=/etc/mysql/server-key.pem

I generated the certificates... 我生成了证书...

openssl genrsa 2048 > ca-key.pem
openssl req -new -x509 -nodes -days 3650 -key ca-key.pem > ca-cert.pem

openssl req -newkey rsa:2048 -days 3560 -nodes -keyout server-key.pem > server-req.pem
openssl rsa -in server-key.pem -out server-key.pem
openssl x509 -req -in server-req.pem -days 3650 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem

openssl req -newkey rsa:2048 -days 3650 -nodes -keyout client-key.pem > client-req.pem
openssl rsa -in client-key.pem -out client-key.pem
openssl x509 -req -in client-req.pem -days 3650 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > client-cert.pem

I have different names for the Common Name value used for the server and client certificates/keys. 对于用于服务器和客户端证书/密钥的“公用名”值,我有不同的名称。 Same names seem to be a problem in some cases. 在某些情况下,相同的名称似乎是一个问题。

I correctly set the permisions of all *.pem files (mysql:adm) which are in /etc/mysql/. 我正确地设置了/ etc / mysql /中所有* .pem文件(mysql:adm)的权限。 After restaring mysql, I can login as root and see that ssl is now supported: 重新启动mysql之后,我可以以root身份登录,现在看到支持ssl:

mysql> show variables like '%ssl%';
+---------------+-----------------------------------+
| Variable_name | Value                             |
+---------------+-----------------------------------+
| have_openssl  | YES                               |
| have_ssl      | YES                               |
| ssl_ca        | /etc/mysql/ca-cert.pem     |
| ssl_capath    |                                   |
| ssl_cert      | /etc/mysql/server-cert.pem |
| ssl_cipher    |                                   |
| ssl_key       | /etc/mysql/server-key.pem  |
+---------------+-----------------------------------+
7 rows in set (0.00 sec)

So.. I generated a test-user to test a ssl connection: 所以..我生成了一个测试用户来测试ssl连接:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'ssluser'@'localhost' IDENTIFIED BY 'password' REQUIRE X509;
mysql> flush privileges;

However, when I try to connect... 但是,当我尝试连接时...

# mysql -u ssluser -p --ssl-ca=ca-cert.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem
Enter password:
ERROR 2026 (HY000): SSL connection error: ASN: bad other signature confirmation

However, my certificates seem to be valid: 但是,我的证书似乎是有效的:

# openssl verify -CAfile ca-cert.pem server-cert.pem client cert.pem
server-cert.pem: OK
client-cert.pem: OK

I tried to solve this problem since several hours, now I do not have any new ideas.. Help is greatly appreciated! 我试图解决这个问题已有几个小时,但现在我没有任何新主意。非常感谢您的帮助!

Solved: Works once the keys are generated with SHA1 已解决:一旦使用SHA1生成了密钥,就可以工作

# Generate a CA key and certificate with SHA1 digest
openssl genrsa 2048 > ca-key.pem
openssl req -sha1 -new -x509 -nodes -days 3650 -key ca-key.pem > ca-cert.pem

# Create server key and certficate with SHA1 digest, sign it and convert
# the RSA key from PKCS #8 (OpenSSL 1.0 and newer) to the old PKCS #1 format
openssl req -sha1 -newkey rsa:2048 -days 730 -nodes -keyout server-key.pem > server-req.pem
openssl x509 -sha1 -req -in server-req.pem -days 730  -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem
openssl rsa -in server-key.pem -out server-key.pem

# Create client key and certificate with SHA digest, sign it and convert
# the RSA key from PKCS #8 (OpenSSL 1.0 and newer) to the old PKCS #1 format
openssl req -sha1 -newkey rsa:2048 -days 730 -nodes -keyout client-key.pem > client-req.pem
openssl x509 -sha1 -req -in client-req.pem -days 730 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > client-cert.pem
openssl rsa -in client-key.pem -out client-key.pem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM