Search code examples
linuxpostgresqlssldatabase-administration

Error When Connecting Postgres Db: Server Certificate Does Not Match Host Name


I installed Postgresql 13 to Centos 8 VM, trying to learn how to make connections secure with ssl. Though completing most of the steps and creating server and client certificates, i can't connect to my database remotely via PgAdmin with verify-full SSL mode. it gives an error like this:

server certificate for "centosnew" does not match host name "192.168.1.153"

"centosnew" is db's hostname and 192.168.1.153 is it's ip address . However, i can connect when i change SSL mode to verify-ca or require modes in PgAdmin.Where could i be doing wrong?

edit: My client's address is in pg_hba.conf looks like this:

hostssl    all             all             192.168.1.165/32        cert

Thanks


Solution

  • In your server certificate, seems like the IP list doesn't include ip 192.168.1.153. Make sure when you create server certificate you have added the Ip where it will listen. You can check if the certificate has the IP in it's list with this link paste your cetificate to decode here.

    Add the Ip in your CommonName also.