1

I have a database server, where I can log in from my machine using psql:

root@engine:/devops# psql -h database -U postgres -d uat

Given the follow result :

psql (9.5.0, server 9.4.5)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

uat=# 

But if I try to connect from my application:

no pg_hba.conf entry for host *** user "postgres", database "uat", SSL off

This is my props.properties used by my application:

uatDb.user=postgres
uatDb.password=***
uatDb.driverClass=org.postgresql.Driver
uatDb.jdbcUrl=jdbc:postgresql://database:5432/uat?ssl=true
uatDb.port=5432
uatDb.name=uat
uatDb.host=database

I even imported the public certificate from my database provider into my application trustore, but doesn't seems to work either.

I wonder why I can connect via psql but my application don't. Any help ?

8
  • As it says, no pg_hba.conf entry Commented Feb 11, 2016 at 9:52
  • But if that's the case, why can I log in using psql but not my application ? Commented Feb 11, 2016 at 9:57
  • psql is using SSL, your application is not. The pg_hba rule also refers to the client's IP address, though you haven't mentioned whether these connections are coming from the same machine. Commented Feb 11, 2016 at 10:05
  • 1
    Oops... Noticed you've got ssl=true in your connection string. Doesn't look like it's taking effect, though I have no idea why... Commented Feb 11, 2016 at 10:07
  • Yep, that's exactly my point @NickBarnes. Even using ssl=true on my url, it doesn't seems to have any effect tough. Commented Feb 11, 2016 at 10:10

1 Answer 1

1

I can confirm that the connections are coming in with SSL off, this is most likely due to the certificate validation restriction. Could you try adding:

sslfactory=org.postgresql.ssl.NonValidatingFactory

and see if this resolves the issue?

Sign up to request clarification or add additional context in comments.

1 Comment

More specifically, appended as: &sslfactory=org.postgresql.ssl.NonValidatingFactory to ssl=true

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.