# 由于 SSLHandshakeException 无法连接到数据库

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com.cn/help/idea/llms.txt).

> **Warning:**
> 由于 [Java 安全策略](https://java.com/en/jre-jdk-cryptoroadmap.html)，TLS 1.0 和 TLS 1.1 协议 [被禁用](https://datatracker.ietf.org/doc/rfc8996/) 并被认为不安全。

由于 [Java 安全策略](https://java.com/en/jre-jdk-cryptoroadmap.html)，TLS 1.0 和 TLS 1.1 协议的使用已被禁用。 这次 Java 更新导致了  `javax.net.ssl.SSLHandshakeException`  错误，当您尝试连接仍然接受这些协议的旧服务器时，便会发生此错误。

作为解决方案，您可以显式启用这些协议。 请注意，这可能导致漏洞问题。 请考虑使用更新版本的 TLS。

## MySQL

Procedure:

1. 通过以下任一方式打开数据源属性：

* 在 数据库 工具窗口工具栏中，点击 ![数据源图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/database-plugin.icons.expui.manageDataSources.svg) 数据源 。

* 请按 `Shift+Enter` (Windows), `⌘ I` (macOS), `⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ I` (macOS System Shortcuts), `Shift+Enter` (XWin), `Shift+Enter` (GNOME), `Shift+Enter` (KDE), `Shift+Enter` (Emacs), `Shift+Enter` (Sublime Text), `⌘ I` (Sublime Text (macOS)), `Shift+Enter` (Visual Studio), `⌘ I` (Visual Studio (macOS)), `Shift+Enter` (NetBeans), `Shift+Enter` (Eclipse), `⌘ I` (Eclipse (macOS)) .

![打开数据源和驱动程序对话框](https://resources.jetbrains.com.cn/help/img/idea/2026.3/open_data_sources_and_drivers_dialog.png)

2. 请选择您要启用已禁用算法的数据源（例如，   MySQL 8.0.3  ）。 以下所需算法可能已被禁用：  `SSLv3` 、  `TLSv1` 、  `TLSv1.1` 、  `RC4` 、  `DES` 、  `MD5withRSA` 、  `DH 密钥大小 < 1024` 、  `EC 密钥大小 < 224` 、  `3DES_EDE_CBC` 、  `anon` 、  `NULL` 、  `include jdk.disabled.namedCurves` 。

3. 在数据源的右侧窗格中，点击   测试连接  。

4. 在通知中，选择您想要执行的操作。 您可以选择以下操作：

* 编辑已禁用的算法 ：打开所选数据源的 高级 选项卡，并将焦点移到 VM 选项 字段。 在 VM 选项 字段中，您可以手动编辑禁用算法的列表（对于 `Djdk.tls.disabledAlgorithms` 选项）。

* 启用 TLSv1 ：从 `Djdk.tls.disabledAlgorithms` 选项中移除 `TLSv1` 。 此操作将启用 TLS 1.0。

* 启用 TLSv1.1 ：从 `Djdk.tls.disabledAlgorithms` 选项中移除 `TLSv1.1` 。 此操作将启用 TLS 1.1。

* 在 JDBC 驱动程序中启用所有协议 ：从 `Djdk.tls.disabledAlgorithms` 选项中移除 `SSLv3` 、 `TLSv1` 、 `TLSv1.1` 、 `RC4` 、 `DES` 、 `MD5withRSA` 、 `DH 密钥大小 < 1024` 、 `EC 密钥大小 < 224` 、 `3DES_EDE_CBC` 、 `anon` 、 `NULL` 、 `include jdk.disabled.namedCurves` 。 此操作启用所有已禁用的算法。

5. 点击   测试连接   看看修复是否有效。

您可以先试试   启用 TLSv1   和   启用 TLSv1.1  。 如果错误仍然发生，请尝试启用其他算法。

![javax.net.ssl.SSLHandshakeException](https://resources.jetbrains.com.cn/help/img/idea/2026.3/db_javax_net_ssl_ssl_handshake_exception.png)

## Microsoft SQL 服务器

Procedure:

1. 在文件浏览器中，创建一个  `custom.java.security`  文件，内容如下：

```
jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, \
     DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
     include jdk.disabled.namedCurves
```

请注意，TLSv1 已从禁用算法列表中移除。

2. 通过以下任一方式打开数据源属性：

* 在 数据库 工具窗口工具栏中，点击 ![数据源图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/database-plugin.icons.expui.manageDataSources.svg) 数据源 。

* 请按 `Shift+Enter` (Windows), `⌘ I` (macOS), `⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ I` (macOS System Shortcuts), `Shift+Enter` (XWin), `Shift+Enter` (GNOME), `Shift+Enter` (KDE), `Shift+Enter` (Emacs), `Shift+Enter` (Sublime Text), `⌘ I` (Sublime Text (macOS)), `Shift+Enter` (Visual Studio), `⌘ I` (Visual Studio (macOS)), `Shift+Enter` (NetBeans), `Shift+Enter` (Eclipse), `⌘ I` (Eclipse (macOS)) .

![打开数据源和驱动程序对话框](https://resources.jetbrains.com.cn/help/img/idea/2026.3/custom.java.security` ，其中  `${PATH_TO_FILE?}` 是创建的  `custom.java.security` 文件的路径。

4. 在主菜单中，前往  `文件 | 使缓存失效 | 仅重启` 。

![“使缓存无效”对话框中的“仅重新启动”选项](https://resources.jetbrains.com.cn/help/img/idea/2026.3/db_invalidate_caches_just_restart.png)

5. 尝试连接到您的 Microsoft SQL 服务器 数据源。

![Snowflake 数据源设置中 custom.java.security 文件的路径](https://resources.jetbrains.com.cn/help/img/idea/2026.3/db_driver_settngs_path_to_custom_java_security_file.png)

