Please some help with an issue I'm getting on the latest Springboot (2.0.3.RELEASE)
I'm getting the following error when trying to access the database. It was working before migrating to the mentioned version of Springboot and Java 10.
Development Enviroment:
-Spring Boot 2.0.3.RELEASE
-JDK / JRE 10 (jdk-10.0.1)
-IDE: Spring Tool Suite 3.9.5.RELEASE
ERROR:
2018-07-19 20:24:37.524 ERROR 12532 --- [ restartedMain] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed. ClientConnectionId:33a45785-248c-4b57-ba29-f8802ddd8b25".
Caused by: java.io.IOException: SQL Server did not return a response. The connection has been closed. ClientConnectionId:33a45785-248c-4b57-ba29-f8802ddd8b25
org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta-data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed. ClientConnectionId:33a45785-248c-4b57-ba29-f8802ddd8b25".
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed. ClientConnectionId:33a45785-248c-4b57-ba29-f8802ddd8b25".
I followed the migration guide but without success. I have also tried different configuration found in the web, but nothing addresses this issue.
Is this happening because of the Spring / Java version.
Note the DataSource configuration in the application.properties:
#CURRENT DATASOURCE CONFIG
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:sqlserver://xxx.xxx.x.xx;databaseName=XXX
spring.datasource.hikari.username=user
spring.datasource.hikari.password=password
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = none
spring.jpa.show-sql=true
#FOLLOWING CONFIG ARE JUST FOR REFERENCE. I TRIED THEM AS PER BLOGS
#spring.datasource.hikari.dataSourceClassName=com.microsoft.sqlserver.jdbc.SQLServerDataSource
#spring.datasource.url=jdbc:sqlserver://XXX.XXX.X.XX;databaseName=XXX
#spring.datasource.url=jdbc:sqlserver://XXX.XXX.X.XX:1433/XXX
#spring.datasource.type=
#spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
#spring.datasource.tomcat.max-active=1
#spring.datasource.username=wstapp
#spring.datasource.password=wstapp#test
#spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
#spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDataSource
#spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
#spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
#spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
I have been looking for a reason this current week. Some advice on a Correct Configuration would be helpful.
Thanks in advance.
It's a MSSQL-JDBC issue. The answer by: Nitin Vavdiya pointed me in the right direction.
I found the "solution" here: https://github.com/Microsoft/mssql-jdbc/issues/719
I just modified the java.security file in the JRE Install folder and remove the value: 3DES_EDE_CBC from the jdk.tls.disabledAlgorithms in the file:
Program Files\Java\"JRE Version"\lib\security
The following is the exact answer that helped me:
To improve the strength of SSL/TLS connections, 3DES cipher suites have been disabled in SSL/TLS connections in the JDK via the jdk.tls.disabledAlgorithms Security Property.
(http://www.oracle.com/technetwork/java/javase/8u171-relnotes-4308888.html)
After changing java.security and removing 3DES_EDE_CBC from jdk.certpath.disabledAlgorithms everything works fine. I'm not sure what needs to be changed in SQLServer config to disable 3DES as an SSL scheme though.
Related
When I try to connect to datasource in WildFly, it says Bad Handshake in MySQL error log and WildFly says:
Failed to add datasource of sql server in wildfly [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (XNIO-1 task-2) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: Could not create connection
The reason is because my TLS version was incompatible, it was trying to use TLS 2, but my MySQL could only accept TLS 1.2. I've just started my job and the project is using legacy software, so for now were forced to use old software.
So my JDBC SQL connection was:
jdbc:mysql://localhost:3306/DATABASE_NAME
And this didn't work, but this did work:
jdbc:mysql://localhost:3306/DATABASE_NAME?enabledTLSProtocols=TLSv1.2
?enabledTLSProtocols=TLSv1.2 is what fixed my issue. Because my MySQL did not support TLS 2, it just didn't communicate well with my version of MySQL.
I am using 14.04 ubuntu linux and for some reason I had to install mysql 5.7.34 version, then the project I was working on gave me a Badhandshake error, I fixed my problem by adding the following in mysqld.cnf.
enabledTLSProtocols=TLSv1.2
Check out the following note from MySQL DEVS.
Note: As of MySQL 5.7.35, the TLSv1 and TLSv1.1 connection protocols
are deprecated and support for them is subject to removal in a future
version of MySQL. See Deprecated TLS Protocols.
Our Java app use jTDS 1.3.1 to connect to SQL Server, which works fine until a client trying to put the database on Azure SQL. The connection failed with the following exception:
java.sql.SQLException: Reason: Login failed due to client TLS version being less than minimal TLS version allowed by the server.
I checked the documentation of jTDS, can't see anyway to specify TLS version. Besides replacing it with MS JDBC driver, has anyone succeeded with other work around?
I don't have access to Azure SQL, so I cannot test if reducing the TLS version to 1.0 would work.
Had this same issue when trying to connect a .Net application to a Azure SQL database in Azure managed instance.
Here's how I solved it.
My previous JDBC URL was this:
jdbc:jtds:sqlserver://my-example-instance.c656df8582985.database.windows.net:1433
I just added ssl=require to the end of the URL, so it became:
jdbc:jtds:sqlserver://my-example-instance.c656df8582985.database.windows.net:1433;ssl=require
Solved the issue by chance. Just need to append ";ssl=request" to the connection string. It looks like by default SSL/TLS is disabled. The error message about TLS version is misleading. Hope this help someone in the future.
I am trying to connect my spring boot application with sql server database but it throwing an Exception and saying :
020-08-18 16:58:11.580 ERROR 14800 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed. .
However I am able to connect with oracle database the issue arises when I try to connect with sql server.
here is the application.properties file
spring.datasource.url=jdbc:sqlserver://192.168.*.*\\DB2008;databaseName=mydbname
spring.datasource.username=myuser
spring.datasource.password=mypassword
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
here is the detailed error:
2020-08-18 16:58:11.580 ERROR 14800 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed. ClientConnectionId:37aa16bd-92f0-4af0-a090-06f2349cb51a".
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2924) ~[mssql-jdbc-7.4.0.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1881) ~[mssql-jdbc-7.4.0.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2484) ~[mssql-jdbc-7.4.0.jre8.jar:na]
In this case can you can try the following steps.
Make sure that your SQL server is running locally(Are you trying to connect to a remove SQL server?)
Alternatively, In your URL after your Data base name use this statement jdbc:mysql://IP:3306/someDatabase?autoReconnect=true&useSSL=false
I have resolved this issue by following the below steps:
Edit C:\Program Files\Java\jdk1.8.0_251\jre\lib\security\java.security
find the below variable it will have multiple comma separated values remove one value which I have mentioned below:
Find: jdk.tls.disabledAlgorithms=
Remove: 3DES_EDE_CBC
This should fix it!
EJB 3
Weblogic: 10.3.x
JDK: 1.7.x
We are facing below error when we enabled SSL for existing TIBCO connection factories/queues. Our requirement was to enable SSL for tibco connection factories / queues.
javax.jms.JMSSecurityException: Failed to connect to any server at: ssl://server_name:44343,ssl://server_name:44343 [Error: invalid name or password: url that returned this exception = SSL://server_name:44343 ]
at com.tibco.tibjms.TibjmsConnection._create(TibjmsConnection.java:1389)
at com.tibco.tibjms.TibjmsConnection.<init>(TibjmsConnection.java:4127)
at com.tibco.tibjms.TibjmsXAConnection.<init>(TibjmsXAConnection.java:30)
at com.tibco.tibjms.TibjmsXAQueueConnection.<init>(TibjmsXAQueueConnection.java:29)
at com.tibco.tibjms.TibjmsxCFImpl._createImpl(TibjmsxCFImpl.java:164)
at com.tibco.tibjms.TibjmsxCFImpl._createConnection(TibjmsxCFImpl.java:253)
at com.tibco.tibjms.TibjmsXAQueueConnectionFactory.createXAQueueConnection(TibjmsXAQueueConnectionFactory.java:129)
at weblogic.ejb.container.internal.JMSConnectionPoller.getXAConnection(JMSConnectionPoller.java:438)
at weblogic.ejb.container.internal.JMSConnectionPoller.createJMSConnection(JMSConnectionPoller.java:2233)
at weblogic.ejb.container.internal.JMSConnectionPoller.connect(JMSConnectionPoller.java:808)
at weblogic.ejb.container.internal.MDConnectionManager.startConnectionPolling(MDConnectionManager.java:265)
at weblogic.ejb.container.manager.MessageDrivenManager.start(MessageDrivenManager.java:657)
at weblogic.ejb.container.deployer.MessageDrivenBeanInfoImpl$DestinationResovler.activateNoneDDMDManager(MessageDrivenBeanInfoImpl.java:2356)
at weblogic.ejb.container.deployer.MessageDrivenBeanInfoImpl$QueueConnectionHandler.handleNoneDD(MessageDrivenBeanInfoImpl.java:2798)
at weblogic.ejb.container.deployer.MessageDrivenBeanInfoImpl$DestinationResovler.resolveDestnationWorkMode(MessageDrivenBeanInfoImpl.java:2289)
at weblogic.ejb.container.deployer.MessageDrivenBeanInfoImpl$DestinationEventHandler.onDestinationsAvailable(MessageDrivenBeanInfoImpl.java:2112)
at weblogic.jms.extensions.JMSDestinationAvailabilityHelper$DestinationAvailabilityListenerWrapper$2.run(JMSDestinationAvailabilityHelper.java:386)
at weblogic.jms.extensions.JMSDestinationAvailabilityHelper$DestinationAvailabilityListenerWrapper.callOutListener(JMSDestinationAvailabilityHelper.java:402)
at weblogic.jms.extensions.JMSDestinationAvailabilityHelper$DestinationAvailabilityListenerWrapper.onDDMembershipChange(JMSDestinationAvailabilityHelper.java:383)
at weblogic.jms.common.CDS$DD2Listener.run(CDS.java:1264)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
The error message shared does show "invalid name or password" as the cause of the error, so I believe that is a good hint to what is causing the error.
Make sure the correct username and password has been configured both in the TIBCO EMS configuration file for the particular instance you are trying to connect to and on Weblogic.
The only other reason I can think of is if the ssl url is incorrect which I believe is not the case.
I am writing a struts2 app and using hibernate for persistence. I deploy may app on heroku and everything works ok, but when ever I run it locally I get:
org.postgresql.util.PSQLException: FATAL:no pg_hba.conf entry for host "xx.xx.xxx.xxx", user "someuser", database "somedatabase", SSL off
I know the problem is I need to connect to the database over ssl but how can I set this up locally?
Add this to the end of your JDBC connection URL:
?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
The key here is "SSL off".
You must use SSL to connect to Heroku. How to enable it depends on the client you are using, which I'm guessing is PgJDBC since you're using Java and Hibernate.
The SSL section of the manual for PgJDBC covers what you need.