报错信息:
shell
D:\self_need_path_files\JDK_8\bin\java.exe "-javaagent:E:\Code_Tool\IDEA\IntelliJ IDEA 2023.1.4\lib\idea_rt.jar=50748:E:\Code_Tool\IDEA\IntelliJ IDEA 2023.1.4\bin" -Dfile.encoding=UTF-8 -classpath D:\self_need_path_files\JDK_8\jre\lib\charsets.jar;D:\self_need_path_files\JDK_8\jre\lib\deploy.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\access-bridge-64.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\cldrdata.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\dnsns.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\jaccess.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\jfxrt.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\localedata.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\nashorn.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\sunec.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\sunjce_provider.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\sunmscapi.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\sunpkcs11.jar;D:\self_need_path_files\JDK_8\jre\lib\ext\zipfs.jar;D:\self_need_path_files\JDK_8\jre\lib\javaws.jar;D:\self_need_path_files\JDK_8\jre\lib\jce.jar;D:\self_need_path_files\JDK_8\jre\lib\jfr.jar;D:\self_need_path_files\JDK_8\jre\lib\jfxswt.jar;D:\self_need_path_files\JDK_8\jre\lib\jsse.jar;D:\self_need_path_files\JDK_8\jre\lib\management-agent.jar;D:\self_need_path_files\JDK_8\jre\lib\plugin.jar;D:\self_need_path_files\JDK_8\jre\lib\resources.jar;D:\self_need_path_files\JDK_8\jre\lib\rt.jar;E:\Undergraduate\School\Courses\大三下\Web程序设计\webapp\demo\out\production\demo;E:\Database_Tool\SQLEXPRADV_x64_CHS\sqljdbc4.jar SqlServerTest
四月 01, 2024 1:33:23 下午 com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
信息: java.security path: D:\self_need_path_files\JDK_8\jre\lib\security
Security providers: [SUN version 1.8, SunRsaSign version 1.8, SunEC version 1.8, SunJSSE version 1.8, SunJCE version 1.8, SunJGSS version 1.8, SunSASL version 1.8, XMLDSig version 1.8, SunPCSC version 1.8, SunMSCAPI version 1.8]
SSLContext provider info: Sun JSSE provider(PKCS12, SunX509/PKIX key/trust factories, SSLv3/TLSv1/TLSv1.1/TLSv1.2/TLSv1.3)
SSLContext provider services:
[SunJSSE: KeyPairGenerator.RSA -> sun.security.rsa.RSAKeyPairGenerator$Legacy
aliases: [OID.1.2.840.113549.1.1, 1.2.840.113549.1.1, 1.2.840.113549.1.1.1]
, SunJSSE: KeyFactory.RSA -> sun.security.rsa.RSAKeyFactory$Legacy
aliases: [OID.1.2.840.113549.1.1, 1.2.840.113549.1.1, 1.2.840.113549.1.1.1]
, SunJSSE: Signature.SHA1withRSA -> sun.security.rsa.RSASignature$SHA1withRSA
aliases: [OID.1.2.840.113549.1.1.5, 1.2.840.113549.1.1.5, 1.3.14.3.2.29]
attributes: {SupportedKeyClasses=java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey}
, SunJSSE: SSLContext.TLS -> sun.security.ssl.SSLContextImpl$TLSContext
aliases: [SSL]
, SunJSSE: SSLContext.TLSv1 -> sun.security.ssl.SSLContextImpl$TLS10Context
aliases: [SSLv3]
, SunJSSE: Signature.MD2withRSA -> sun.security.rsa.RSASignature$MD2withRSA
aliases: [OID.1.2.840.113549.1.1.2, 1.2.840.113549.1.1.2]
attributes: {SupportedKeyClasses=java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey}
, SunJSSE: Signature.MD5withRSA -> sun.security.rsa.RSASignature$MD5withRSA
aliases: [OID.1.2.840.113549.1.1.4, 1.2.840.113549.1.1.4]
attributes: {SupportedKeyClasses=java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey}
, SunJSSE: KeyStore.PKCS12 -> sun.security.pkcs12.PKCS12KeyStore
, SunJSSE: TrustManagerFactory.SunX509 -> sun.security.ssl.TrustManagerFactoryImpl$SimpleFactory
, SunJSSE: KeyManagerFactory.SunX509 -> sun.security.ssl.KeyManagerFactoryImpl$SunX509
, SunJSSE: TrustManagerFactory.PKIX -> sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory
aliases: [SunPKIX, X509, X.509]
, SunJSSE: KeyManagerFactory.NewSunX509 -> sun.security.ssl.KeyManagerFactoryImpl$X509
aliases: [PKIX]
, SunJSSE: SSLContext.Default -> sun.security.ssl.SSLContextImpl$DefaultSSLContext
, SunJSSE: SSLContext.TLSv1.1 -> sun.security.ssl.SSLContextImpl$TLS11Context
, SunJSSE: Signature.MD5andSHA1withRSA -> sun.security.ssl.RSASignature
, SunJSSE: SSLContext.TLSv1.3 -> sun.security.ssl.SSLContextImpl$TLS13Context
, SunJSSE: SSLContext.TLSv1.2 -> sun.security.ssl.SSLContextImpl$TLS12Context
]
java.ext.dirs: D:\self_need_path_files\JDK_8\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:"The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]"。 ClientConnectionId:75cdc2ce-971c-450f-b033-546325121f42
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1668)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1323)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at SqlServerTest.main(SqlServerTest.java:18)
Caused by: javax.net.ssl.SSLHandshakeException: The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]
at sun.security.ssl.Alert.createSSLException(Alert.java:131)
at sun.security.ssl.Alert.createSSLException(Alert.java:117)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:364)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:320)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:311)
at sun.security.ssl.ServerHello$ServerHelloConsumer.onServerHello(ServerHello.java:941)
at sun.security.ssl.ServerHello$ServerHelloConsumer.consume(ServerHello.java:868)
at sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:376)
at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:479)
at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:457)
at sun.security.ssl.TransportContext.dispatch(TransportContext.java:200)
at sun.security.ssl.SSLTransport.decode(SSLTransport.java:155)
at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1320)
at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1233)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:417)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:389)
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1618)
... 7 more
进程已结束,退出代码1
将TLSv1
和TLSv1.1
删除,修改后为:
之后重启即可。