Я пытаюсь перенести свой проект с java 6 на java 8. Мой код устанавливает соединение с SQL сервером. Поэтому после того, как я изменил версию java с 6 на 8, я получаю следующую ошибку:
SQL Express 2014. Я использую sqljdbc4.2
com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "java.security.ProviderException: Could not derive key". ClientConnectionId:fe7be29f-34c6-4c47-96f5-4f8075c9f782
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1749)
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1704)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1402)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1069)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:905)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:452)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1014)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
Кажется, не удалось найти поставщика услуг в java 8. Я попытался поставить банку BountyCastle (bcprov-jdk15on-165) и изменил java .security на security.provider.2=org.bouncycastle.jce.provider.BouncyCastleProvider
, чтобы сделать запись BouncyCastleProvider, но затем я также получаю Ошибка SSLHandshake
Caused by: javax.net.ssl.SSLException: java.security.ProviderException: Could not derive key
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1903)
at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1886)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1402)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1630)
... 24 more
Caused by: java.security.ProviderException: Could not derive key
at sun.security.ec.ECDHKeyAgreement.engineGenerateSecret(ECDHKeyAgreement.java:133)
at sun.security.ec.ECDHKeyAgreement.engineGenerateSecret(ECDHKeyAgreement.java:163)
at javax.crypto.KeyAgreement.generateSecret(KeyAgreement.java:648)
at sun.security.ssl.ECDHCrypt.getAgreedSecret(ECDHCrypt.java:102)
at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1122)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:369)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1037)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:965)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
... 26 more
Caused by: java.security.InvalidAlgorithmParameterException
at sun.security.ec.ECDHKeyAgreement.deriveKey(Native Method)
at sun.security.ec.ECDHKeyAgreement.engineGenerateSecret(ECDHKeyAgreement.java:130)