Handling of some problems with JDBC connection to SqlServer 2008 R2 database

The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption

Modify the contents of java.security

You need to find java.security in the java installation directory, the default path :C:\Program Files\Java\jdk1.8.0_361\jre\lib\security

Modify jdk.tls.disabledAlgorithms

jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048

# 这个是原有的配置(已封存)
#jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \
#    DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
#    include jdk.disabled.namedCurves

# 这个是修改后的配置,注意这里将TLSv1, TLSv1.1去掉以确保SSL加密生效
jdk.tls.disabledAlgorithms=SSLv3, RC4,  MD5withRSA, \
DH keySize < 1024, EC keySize < 224, DES40_CBC, RC4_40, \
include jdk.disabled.namedCurves

Modify jdk.tls.legacyAlgorithms

# 这个是原有配置(已封存)
#jdk.tls.legacyAlgorithms= \
#        K_NULL, C_NULL, M_NULL, \
#        DH_anon, ECDH_anon, \
#        RC4_128, RC4_40, DES_CBC, DES40_CBC, \
#        3DES_EDE_CBC

# 这个是修改后的配置,这里将“3DES_EDE_CBC”删除了
jdk.tls.legacyAlgorithms= \
K_NULL, C_NULL, M_NULL, \
DH_anon, ECDH_anon, \
RC4_128, RC4_40, DES_CBC, DES40_CBC

Original portal: https://blog.51cto.com/u_15761576/6109287

Supplementary Note

In addition, I tried several versions of the SQLSever driver version, and finally determined the version mssql-jdbc8.2.2.jre8

mssql-jdbc8.2.2.jre8 download link: https://download.microsoft.com/download/5/3/f/53fcc3e2-e91f-48f4-bed6-5d79e4fc9fbe/sqljdbc_8.2.2.0_chs.zip

The above are some of the problems I personally encountered and the solutions to share with you, I hope it will be helpful to you

Guess you like

Origin blog.csdn.net/weixin_44792145/article/details/129527183