欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

SSLHandshakeException: No appropriate protocol

最编程 2024-03-25 07:55:01
...

SSLHandshakeException: No appropriate protocol


最近 很多 询问关于 DataGrip或其他JetBrains`家IDE的MySQL数据库配置中报错的问题。具体的报错信息大概是这样的:

javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
      The following required algorithms might be disabled: SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, include jdk.disabled.namedCurves. Edit the list of disabled algorithms to include required algorithms. You can try to enable TLSv1 or TLSv1.1 first.
      JDBC driver may have disabled TLS 1.1 and its earlier versions.


这个问题我在IDE更新至2021.2配置数据库时也曾遇到过,当时随手给解决了,以为这个问题并不需要记录。

故而我做了个决定(并不违背祖宗):把我解决问题的办法记录下来,以供大家参考。


方法一

建立一个文件(我放在~/.custom.java.security,记住这个路径),内容如下:


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

在IDE配置数据源时,点击Advanced选项卡,在VM options:中输入(其中=后填写上面那个绝对路径):


"-Djava.security.properties=${HOME}/.custom.java.security"


OK按钮,现在就可以愉快的操作数据库了。


方法二


在IDE配置数据源时,点击Advanced选项卡,在VM options:中输入(其实基本就是方法一的文件内容):


"-Djdk.tls.disabledAlgorithms=SSLv3, TLSv1.1, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySi

OK按钮,现在就可以愉快的操作数据库了。


方法三


  • 配置全局的java.security.properties,内容也就是上面那些。不过,此法侵入性太高,不够灵活。这里不详细介绍,感兴趣自己去试试。

好了,以上就是解决开头提到问题的详细方法了。当然,我使用的是方法一,我觉得它够灵活,好配置,好复制。