'TLSv1.2 on tomcat jdbc connection
My project setup uses mssql, tomcat9.0.59,java 1.8_322 and MSSql driver is mssql-jdbc-10.2.0.jre8.jar.
TLS 1.2 is enabled database server, after patching. Question is, How to configure jdbc connection properties to use TLSv1.2 protocol?
Tried using below configuration, but it is not working.
<Resource name="jdbc/connectionpool" auth="Container" type="javax.sql.DataSource"
username="username" password="password"
url="jdbc:sqlserver://IP:1433;databaseName=testDb;encrypt=true;trustServerCertificate=true;"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
initialSize="5" maxWaitMillis="5000" maxTotal="600" maxIdle="50"
validationQuery="select 1;" poolPreparedStatements="true"/>
below error is throwing while starting the tomcat.
13-May-2022 11:25:25.013 WARNING [main] org.apache.naming.NamingContext.lookup Unexpected exception resolving reference
java.sql.SQLException: Cannot create PoolableConnectionFactory (The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "No appropriate protocol (protocol is disabled or cipher suites are inappropriate)". ClientConnectionId:e3c2518c-0eb4-4c1d-b223-7f2a1da3bd7a)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:653)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:532)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getLogWriter(BasicDataSource.java:1057)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.createDataSource(BasicDataSourceFactory.java:308)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance(BasicDataSourceFactory.java:399)
at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:96)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:332)
at org.apache.naming.NamingContext.lookup(NamingContext.java:864)
at org.apache.naming.NamingContext.lookup(NamingContext.java:158)
at org.apache.naming.NamingContext.lookup(NamingContext.java:850)
at org.apache.naming.NamingContext.lookup(NamingContext.java:172)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|