Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"HostName not verified error message" on SSL connection in postgresql

I created server.crt, server.key and root.crt files on Centos 7 and put the same onto the C:\Users\xxxx\AppData\Roaming\postgresql folder in windows as i am running the postgresql server on windows. Now on running my applications using SSL, i am getting the error as

"The host name could not be verified"

Any help please.

like image 371
ashish chauhan Avatar asked May 03 '18 09:05

ashish chauhan


People also ask

What is SSL hostname verification?

A host name verifier ensures the host name in the URL to which the client connects matches the host name in the digital certificate that the server sends back as part of the SSL connection.

How disable SSL hostname verification?

Click the name of the server for which you want to disable host name verification. Select Configuration > SSL , and click Advanced at the bottom of the page. Set the Hostname Verification field to None.

What is SSL connection in PostgreSQL?

Using SSL, you can encrypt a PostgreSQL connection between your applications and your PostgreSQL DB instances. By default, RDS for PostgreSQL uses and expects all clients to connect using SSL/TLS, but you can also require it. RDS for PostgreSQL supports Transport Layer Security (TLS) versions 1.1 and 1.2.


2 Answers

I am using JetBrains Data Grip to access Postgres dbs on Heroku, and got the same error in the latest JDBC driver version. That's how I solved it (using answers provided here).

Set the following in the Advanced tab:

ssl=true

sslmode=require

sslfactory=org.postgresql.ssl.NonValidatingFactory

(I updated sslmode value from verify-ca to required because it works with Heroku Postgres now)

like image 52
mohghaderi Avatar answered Sep 16 '22 20:09

mohghaderi


If you don't care about hostname verification while still wanting to use a certificate, you can use the additional parameter sslmode=verify-ca as a connection parameter or as part of the URL to disable hostname verification while retaining certificate verification.

like image 33
Pt. Terk Avatar answered Sep 16 '22 20:09

Pt. Terk