I installed the PostgreSql-12 using homebrew on my macos. It's running fine and able to use in the PgAdmin but throwing below error while using the DB in the java Spring boot app
Caused by: org.flywaydb.core.internal.exception.FlywaySqlException: Unable to obtain connection from database: An error occurred while setting up the SSL connection.
SQL State : 08P01
Error Code : 0
Message : An error occurred while setting up the SSL connection.
What I have tried - disabling ssl = off in the postgresql.conf
Below is the pg_hba.conf file -
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
Reproducing Steps -
- Install postgresql using brew - brew install postgresql@12
- datasource url used in the spring datasource -
jdbc:postgresql://localhost:5432/test_db?reWriteBatchedInserts=true - Application run failing with the SSL error
StackTrace -
SQL State : 08P01
Error Code : 0
Message : An error occurred while setting up the SSL connection.
at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:60) ~[flyway-core-9.16.3.jar:na]
at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:74) ~[flyway-core-9.16.3.jar:na]
at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:140) ~[flyway-core-9.16.3.jar:na]
at org.flywaydb.core.Flyway.migrate(Flyway.java:140) ~[flyway-core-9.16.3.jar:na]
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66) ~[spring-boot-autoconfigure-3.1.0.jar:3.1.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.9.jar:6.0.9]
... 18 common frames omitted
Caused by: org.postgresql.util.PSQLException: An error occurred while setting up the SSL connection.
at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:624) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:191) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:258) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:263) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.Driver.makeConnection(Driver.java:443) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.Driver.connect(Driver.java:297) ~[postgresql-42.6.0.jar:42.6.0]
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681) ~[java.sql:na]
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:190) ~[java.sql:na]
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:155) ~[spring-jdbc-6.0.9.jar:6.0.9]
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:146) ~[spring-jdbc-6.0.9.jar:6.0.9]
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:205) ~[spring-jdbc-6.0.9.jar:6.0.9]
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:169) ~[spring-jdbc-6.0.9.jar:6.0.9]
at com.fareye.entityframework.multitenant.CustomConnectionProvider.getConnection(CustomConnectionProvider.java:20) ~[fareye-entity-framework-lib-1.0.1-SNAPSHOT.jar:na]
at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:48) ~[flyway-core-9.16.3.jar:na]
... 24 common frames omitted
Any help would be appreciated.