AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 333611
Accepted
Potter
Potter
Asked: 2023-11-30 22:55:19 +0800 CST2023-11-30 22:55:19 +0800 CST 2023-11-30 22:55:19 +0800 CST

MySQL - 具有“REQUIRE SSL”选项的用户是否仍然能够在不提供任何 SSL 或 CA 证书的情况下登录?

  • 772

我的 MySQL 服务器已正确配置以下参数

mysql> show global variables like '%have_ssl%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_ssl      | YES   |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show global variables like 'ssl_ca';
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| ssl_ca        | ca.pem |
+---------------+--------+
1 row in set (0.00 sec)

mysql> show global variables like 'ssl_cert';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| ssl_cert      | server-cert.pem |
+---------------+-----------------+
1 row in set (0.00 sec)

mysql> show global variables like 'ssl_key';
+---------------+----------------+
| Variable_name | Value          |
+---------------+----------------+
| ssl_key       | server-key.pem |
+---------------+----------------+
1 row in set (0.00 sec)
mysql> show global variables like 'datadir';
+---------------+---------+
| Variable_name | Value   |
+---------------+---------+
| datadir       | /dados/ |
+---------------+---------+
1 row in set (0.00 sec)

这些文件存在于datadir

[root@mysqlen1 dados]# ls -l ca.pem server-cert.pem server-key.pem
-rw-r--r-- 1 mysql mysql 1112 Nov  3 10:28 ca.pem
-rw-r--r-- 1 mysql mysql 1112 Nov  3 10:28 server-cert.pem
-rw------- 1 mysql mysql 1680 Nov  3 10:28 server-key.pem

然后我创建一个用户:

mysql> create user 'teste'@'%' identified by 'teste123' require ssl;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

我可以使用证书进行连接

[root@TCCPUC-ENGDADOS:~]# mysql -uteste -p'teste123' -h 192.168.0.110 --ssl-ca=ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

但也没有证书

[root@TCCPUC-ENGDADOS:~]# mysql -uteste -p'teste123' -h 192.168.0.110
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

它是否正确?我可以强制用户仅使用这些证书登录吗?

mysql
  • 2 2 个回答
  • 40 Views

2 个回答

  • Voted
  1. Best Answer
    Bill Karwin
    2023-12-01T04:48:16+08:002023-12-01T04:48:16+08:00

    指定用户REQUIRE SSL并不意味着该用户需要证书。SSL 用于加密传输,而证书用于身份验证。

    您可以创建一个用户,并REQUIRE X509选择强制客户端使用证书。

    • 1
  2. Ergest Basha
    2023-11-30T23:20:58+08:002023-11-30T23:20:58+08:00

    您可以mysqld使用require_secure_transport进行配置

    客户端与服务器的连接是否需要使用某种形式的安全传输。启用此变量后,服务器仅允许使用 TLS/SSL 加密的 TCP/IP 连接,或使用套接字文件(在 Unix 上)或共享内存(在 Windows 上)的连接。服务器拒绝非安全连接尝试,该连接尝试会失败并出现 ER_SECURE_TRANSPORT_REQUIRED 错误。

    此功能补充了优先考虑的每帐户 SSL 要求。例如,如果使用 REQUIRE SSL 定义帐户,则启用 require_secure_transport 无法使用该帐户通过 Unix 套接字文件进行连接。

    加密连接的服务器端启动配置

    [mysqld]
    ssl_ca=ca.pem
    ssl_cert=server-cert.pem
    ssl_key=server-key.pem
    require_secure_transport=ON
    
    • 0

相关问题

  • 是否有任何 MySQL 基准测试工具?[关闭]

  • 我在哪里可以找到mysql慢日志?

  • 如何优化大型数据库的 mysqldump?

  • 什么时候是使用 MariaDB 而不是 MySQL 的合适时机,为什么?

  • 组如何跟踪数据库架构更改?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve